diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-07-16 12:38:28 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-07-16 12:38:28 +0000 |
commit | b4a203c2fd2cdebc74c37215455ec2545c8bc99e (patch) | |
tree | 01099f260a73d85ade9d0e18b5f83d178ade8e85 /src/fs/gnunet-service-fs_cp.c | |
parent | f73155b9b44f757ef175f7334cf2ff029e1642dd (diff) | |
download | gnunet-b4a203c2fd2cdebc74c37215455ec2545c8bc99e.tar.gz gnunet-b4a203c2fd2cdebc74c37215455ec2545c8bc99e.zip |
error handling
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index f031688c3..bca07db32 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -313,6 +313,11 @@ struct GSF_ConnectedPeer | |||
313 | */ | 313 | */ |
314 | void *creation_cb_cls; | 314 | void *creation_cb_cls; |
315 | 315 | ||
316 | /** | ||
317 | * Handle to the PEERSTORE iterate request for peer respect value | ||
318 | */ | ||
319 | struct GNUNET_PEERSTORE_IterateContext *respect_iterate_req; | ||
320 | |||
316 | }; | 321 | }; |
317 | 322 | ||
318 | 323 | ||
@@ -572,17 +577,9 @@ peer_respect_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) | |||
572 | { | 577 | { |
573 | struct GSF_ConnectedPeer *cp = cls; | 578 | struct GSF_ConnectedPeer *cp = cls; |
574 | 579 | ||
580 | cp->respect_iterate_req = NULL; | ||
575 | if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size)) | 581 | if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size)) |
576 | cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value); | 582 | cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value); |
577 | cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); | ||
578 | GNUNET_break (GNUNET_OK == | ||
579 | GNUNET_CONTAINER_multipeermap_put (cp_map, | ||
580 | GSF_connected_peer_get_identity2_ (cp), | ||
581 | cp, | ||
582 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
583 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), | ||
584 | GNUNET_CONTAINER_multipeermap_size (cp_map), | ||
585 | GNUNET_NO); | ||
586 | GSF_push_start_ (cp); | 583 | GSF_push_start_ (cp); |
587 | if (NULL != cp->creation_cb) | 584 | if (NULL != cp->creation_cb) |
588 | cp->creation_cb (cp->creation_cb_cls, cp); | 585 | cp->creation_cb (cp->creation_cb_cls, cp); |
@@ -612,10 +609,21 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, | |||
612 | cp->rc = | 609 | cp->rc = |
613 | GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE, | 610 | GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE, |
614 | &ats_reserve_callback, cp); | 611 | &ats_reserve_callback, cp); |
612 | cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); | ||
613 | GNUNET_break (GNUNET_OK == | ||
614 | GNUNET_CONTAINER_multipeermap_put (cp_map, | ||
615 | GSF_connected_peer_get_identity2_ (cp), | ||
616 | cp, | ||
617 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
618 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), | ||
619 | GNUNET_CONTAINER_multipeermap_size (cp_map), | ||
620 | GNUNET_NO); | ||
615 | cp->creation_cb = creation_cb; | 621 | cp->creation_cb = creation_cb; |
616 | cp->creation_cb_cls = creation_cb_cls; | 622 | cp->creation_cb_cls = creation_cb_cls; |
617 | GNUNET_PEERSTORE_iterate (peerstore, "fs", peer, "respect", | 623 | cp->respect_iterate_req = |
618 | GNUNET_TIME_UNIT_FOREVER_REL, &peer_respect_cb, cp); | 624 | GNUNET_PEERSTORE_iterate (peerstore, "fs", peer, "respect", |
625 | GNUNET_TIME_UNIT_FOREVER_REL, &peer_respect_cb, | ||
626 | cp); | ||
619 | } | 627 | } |
620 | 628 | ||
621 | 629 | ||
@@ -1509,6 +1517,11 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
1509 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), | 1517 | GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), |
1510 | GNUNET_CONTAINER_multipeermap_size (cp_map), | 1518 | GNUNET_CONTAINER_multipeermap_size (cp_map), |
1511 | GNUNET_NO); | 1519 | GNUNET_NO); |
1520 | if (NULL != cp->respect_iterate_req) | ||
1521 | { | ||
1522 | GNUNET_PEERSTORE_iterate_cancel (cp->respect_iterate_req); | ||
1523 | cp->respect_iterate_req = NULL; | ||
1524 | } | ||
1512 | if (NULL != cp->migration_pth) | 1525 | if (NULL != cp->migration_pth) |
1513 | { | 1526 | { |
1514 | GSF_peer_transmit_cancel_ (cp->migration_pth); | 1527 | GSF_peer_transmit_cancel_ (cp->migration_pth); |