From: Omar Tarabai Date: Wed, 16 Jul 2014 12:38:28 +0000 (+0000) Subject: error handling X-Git-Tag: initial-import-from-subversion-38251~3471 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b4a203c2fd2cdebc74c37215455ec2545c8bc99e;p=oweals%2Fgnunet.git error handling --- 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 */ 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);