From 7d77825b6694b3d17537b5cc4ce74c1e365764c2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 29 Nov 2013 17:22:08 +0000 Subject: -fix #3133 --- src/fs/gnunet-service-fs_mesh_client.c | 16 +++++++++++----- src/fs/gnunet-service-fs_pr.c | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'src/fs') diff --git a/src/fs/gnunet-service-fs_mesh_client.c b/src/fs/gnunet-service-fs_mesh_client.c index 97a2fa36e..7bf6fb115 100644 --- a/src/fs/gnunet-service-fs_mesh_client.c +++ b/src/fs/gnunet-service-fs_mesh_client.c @@ -368,7 +368,7 @@ transmit_pending (struct MeshHandle *mh) /** - * Closure for 'handle_reply'. + * Closure for handle_reply(). */ struct HandleReplyClosure { @@ -677,6 +677,14 @@ cleaner_cb (void *cls, mh->channel = NULL; while (NULL != (sr = mh->pending_head)) GSF_mesh_query_cancel (sr); + /* first remove `mh` from the `mesh_map`, so that if the + callback from `free_waiting_entry()` happens to re-issue + the request, we don't immediately have it back in the + `waiting_map`. */ + GNUNET_assert (GNUNET_OK == + GNUNET_CONTAINER_multipeermap_remove (mesh_map, + &mh->target, + mh)); GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map, &free_waiting_entry, mh); @@ -686,10 +694,8 @@ cleaner_cb (void *cls, GNUNET_SCHEDULER_cancel (mh->timeout_task); if (GNUNET_SCHEDULER_NO_TASK != mh->reset_task) GNUNET_SCHEDULER_cancel (mh->reset_task); - GNUNET_assert (GNUNET_OK == - GNUNET_CONTAINER_multipeermap_remove (mesh_map, - &mh->target, - mh)); + GNUNET_assert (0 == + GNUNET_CONTAINER_multihashmap_size (mh->waiting_map)); GNUNET_CONTAINER_multihashmap_destroy (mh->waiting_map); GNUNET_free (mh); } diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 105093361..e5a789a2b 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -719,10 +719,8 @@ GSF_iterate_pending_requests_ (GSF_PendingRequestIterator it, void *cls) } - - /** - * Closure for "process_reply" function. + * Closure for process_reply() function. */ struct ProcessReplyClosure { @@ -800,7 +798,9 @@ update_request_performance_data (struct ProcessReplyClosure *prq, * @return #GNUNET_YES (we should continue to iterate) */ static int -process_reply (void *cls, const struct GNUNET_HashCode * key, void *value) +process_reply (void *cls, + const struct GNUNET_HashCode *key, + void *value) { struct ProcessReplyClosure *prq = cls; struct GSF_PendingRequest *pr = value; @@ -1151,10 +1151,10 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr) */ static void mesh_reply_proc (void *cls, - enum GNUNET_BLOCK_Type type, - struct GNUNET_TIME_Absolute expiration, - size_t data_size, - const void *data) + enum GNUNET_BLOCK_Type type, + struct GNUNET_TIME_Absolute expiration, + size_t data_size, + const void *data) { struct GSF_PendingRequest *pr = cls; struct ProcessReplyClosure prq; @@ -1173,10 +1173,10 @@ mesh_reply_proc (void *cls, /* retry -- without delay, as this is non-anonymous and mesh/mesh connect will take some time anyway */ pr->mesh_request = GSF_mesh_query (pr->public_data.target, - &pr->public_data.query, - pr->public_data.type, - &mesh_reply_proc, - pr); + &pr->public_data.query, + pr->public_data.type, + &mesh_reply_proc, + pr); return; } if (GNUNET_YES != -- cgit v1.2.3