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) |
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 f031688c32..bca07db328 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -313,6 +313,11 @@ struct GSF_ConnectedPeer */ void *creation_cb_cls; + /** + * Handle to the PEERSTORE iterate request for peer respect value + */ + struct GNUNET_PEERSTORE_IterateContext *respect_iterate_req; + }; @@ -572,17 +577,9 @@ peer_respect_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) { struct GSF_ConnectedPeer *cp = cls; + cp->respect_iterate_req = NULL; if ((NULL != record) && (sizeof (cp->disk_respect) == record->value_size)) cp->disk_respect = cp->ppd.respect = *((uint32_t *)record->value); - cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); - GNUNET_break (GNUNET_OK == - GNUNET_CONTAINER_multipeermap_put (cp_map, - GSF_connected_peer_get_identity2_ (cp), - cp, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); - GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), - GNUNET_CONTAINER_multipeermap_size (cp_map), - GNUNET_NO); GSF_push_start_ (cp); if (NULL != cp->creation_cb) cp->creation_cb (cp->creation_cb_cls, cp); @@ -612,10 +609,21 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer, cp->rc = GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE, &ats_reserve_callback, cp); + cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); + GNUNET_break (GNUNET_OK == + GNUNET_CONTAINER_multipeermap_put (cp_map, + GSF_connected_peer_get_identity2_ (cp), + cp, + GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), + GNUNET_CONTAINER_multipeermap_size (cp_map), + GNUNET_NO); cp->creation_cb = creation_cb; cp->creation_cb_cls = creation_cb_cls; - GNUNET_PEERSTORE_iterate (peerstore, "fs", peer, "respect", - GNUNET_TIME_UNIT_FOREVER_REL, &peer_respect_cb, cp); + cp->respect_iterate_req = + GNUNET_PEERSTORE_iterate (peerstore, "fs", peer, "respect", + GNUNET_TIME_UNIT_FOREVER_REL, &peer_respect_cb, + cp); } @@ -1509,6 +1517,11 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), GNUNET_CONTAINER_multipeermap_size (cp_map), GNUNET_NO); + if (NULL != cp->respect_iterate_req) + { + GNUNET_PEERSTORE_iterate_cancel (cp->respect_iterate_req); + cp->respect_iterate_req = NULL; + } if (NULL != cp->migration_pth) { GSF_peer_transmit_cancel_ (cp->migration_pth); |