commit 9d840e937d7e69f585cd5536a63ad6629412c0d6
parent 7faa62d0e03329190ad48489d09daa087c9456e2
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 27 Nov 2013 21:02:36 +0000
-attempting to address #3133
Diffstat:
2 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/src/fs/gnunet-service-fs_mesh_client.c b/src/fs/gnunet-service-fs_mesh_client.c
@@ -407,7 +407,7 @@ struct HandleReplyClosure
* @param cls the 'struct HandleReplyClosure'
* @param key the key of the entry in the map (the query)
* @param value the 'struct GSF_MeshRequest' to handle result for
- * @return GNUNET_YES (continue to iterate)
+ * @return #GNUNET_YES (continue to iterate)
*/
static int
handle_reply (void *cls,
@@ -422,6 +422,7 @@ handle_reply (void *cls,
hrc->expiration,
hrc->data_size,
hrc->data);
+ sr->proc = NULL;
GSF_mesh_query_cancel (sr);
hrc->found = GNUNET_YES;
return GNUNET_YES;
@@ -591,7 +592,17 @@ void
GSF_mesh_query_cancel (struct GSF_MeshRequest *sr)
{
struct MeshHandle *mh = sr->mh;
+ GSF_MeshReplyProcessor p;
+ p = sr->proc;
+ sr->proc = NULL;
+ if (NULL != p)
+ {
+ /* signal failure / cancellation to callback */
+ p (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ 0, NULL);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cancelled query for %s via mesh to %s\n",
GNUNET_h2s (&sr->query),
@@ -619,10 +630,10 @@ GSF_mesh_query_cancel (struct GSF_MeshRequest *sr)
* call the 'proc' continuation and release associated
* resources.
*
- * @param cls the 'struct MeshHandle'
+ * @param cls the `struct MeshHandle`
* @param key the key of the entry in the map (the query)
- * @param value the 'struct GSF_MeshRequest' to clean up
- * @return GNUNET_YES (continue to iterate)
+ * @param value the `struct GSF_MeshRequest` to clean up
+ * @return #GNUNET_YES (continue to iterate)
*/
static int
free_waiting_entry (void *cls,
@@ -631,9 +642,6 @@ free_waiting_entry (void *cls,
{
struct GSF_MeshRequest *sr = value;
- sr->proc (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- 0, NULL);
GSF_mesh_query_cancel (sr);
return GNUNET_YES;
}
@@ -660,12 +668,7 @@ cleaner_cb (void *cls,
GNUNET_assert (channel == mh->channel);
mh->channel = NULL;
while (NULL != (sr = mh->pending_head))
- {
- sr->proc (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
- GNUNET_TIME_UNIT_FOREVER_ABS,
- 0, NULL);
GSF_mesh_query_cancel (sr);
- }
GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map,
&free_waiting_entry,
mh);
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
@@ -595,7 +595,14 @@ clean_request (void *cls, const struct GNUNET_HashCode * key, void *value)
GSF_LocalLookupContinuation cont;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Cleaning up pending request for `%s'.\n", GNUNET_h2s (key));
+ "Cleaning up pending request for `%s'.\n",
+ GNUNET_h2s (key));
+ if (NULL != pr->mesh_request)
+ {
+ pr->mesh_retry_count = MESH_RETRY_MAX;
+ GSF_mesh_query_cancel (pr->mesh_request);
+ pr->mesh_request = NULL;
+ }
if (NULL != (cont = pr->llc_cont))
{
pr->llc_cont = NULL;
@@ -627,11 +634,6 @@ clean_request (void *cls, const struct GNUNET_HashCode * key, void *value)
GNUNET_DHT_get_stop (pr->gh);
pr->gh = NULL;
}
- if (NULL != pr->mesh_request)
- {
- GSF_mesh_query_cancel (pr->mesh_request);
- pr->mesh_request = NULL;
- }
if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
{
GNUNET_SCHEDULER_cancel (pr->warn_task);
@@ -668,6 +670,12 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
* but do NOT remove from our data-structures, we still need it there
* to prevent the request from looping */
pr->rh = NULL;
+ if (NULL != pr->mesh_request)
+ {
+ pr->mesh_retry_count = MESH_RETRY_MAX;
+ GSF_mesh_query_cancel (pr->mesh_request);
+ pr->mesh_request = NULL;
+ }
if (NULL != (cont = pr->llc_cont))
{
pr->llc_cont = NULL;
@@ -684,11 +692,6 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
GNUNET_DHT_get_stop (pr->gh);
pr->gh = NULL;
}
- if (NULL != pr->mesh_request)
- {
- GSF_mesh_query_cancel (pr->mesh_request);
- pr->mesh_request = NULL;
- }
if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
{
GNUNET_SCHEDULER_cancel (pr->warn_task);
@@ -1143,7 +1146,7 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
* @param cls the pending request struct
* @param type type of the block, ANY on error
* @param expiration expiration time for the block
- * @param data_size number of bytes in 'data', 0 on error
+ * @param data_size number of bytes in @a data, 0 on error
* @param data reply block data, NULL on error
*/
static void
@@ -1162,11 +1165,11 @@ mesh_reply_proc (void *cls,
{
GNUNET_break (NULL == data);
GNUNET_break (0 == data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Error retrieiving block via mesh\n");
pr->mesh_retry_count++;
if (pr->mesh_retry_count >= MESH_RETRY_MAX)
return; /* give up on mesh */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Error retrieiving block via mesh\n");
/* 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,