aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-27 21:02:36 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-27 21:02:36 +0000
commit9d840e937d7e69f585cd5536a63ad6629412c0d6 (patch)
treeb068060020f63c918cd0de09082a5b552ddc817a
parent7faa62d0e03329190ad48489d09daa087c9456e2 (diff)
downloadgnunet-9d840e937d7e69f585cd5536a63ad6629412c0d6.tar.gz
gnunet-9d840e937d7e69f585cd5536a63ad6629412c0d6.zip
-attempting to address #3133
-rw-r--r--src/fs/gnunet-service-fs_mesh_client.c27
-rw-r--r--src/fs/gnunet-service-fs_pr.c31
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
index c30a38cf7..57eb34d04 100644
--- a/src/fs/gnunet-service-fs_mesh_client.c
+++ b/src/fs/gnunet-service-fs_mesh_client.c
@@ -407,7 +407,7 @@ struct HandleReplyClosure
407 * @param cls the 'struct HandleReplyClosure' 407 * @param cls the 'struct HandleReplyClosure'
408 * @param key the key of the entry in the map (the query) 408 * @param key the key of the entry in the map (the query)
409 * @param value the 'struct GSF_MeshRequest' to handle result for 409 * @param value the 'struct GSF_MeshRequest' to handle result for
410 * @return GNUNET_YES (continue to iterate) 410 * @return #GNUNET_YES (continue to iterate)
411 */ 411 */
412static int 412static int
413handle_reply (void *cls, 413handle_reply (void *cls,
@@ -422,6 +422,7 @@ handle_reply (void *cls,
422 hrc->expiration, 422 hrc->expiration,
423 hrc->data_size, 423 hrc->data_size,
424 hrc->data); 424 hrc->data);
425 sr->proc = NULL;
425 GSF_mesh_query_cancel (sr); 426 GSF_mesh_query_cancel (sr);
426 hrc->found = GNUNET_YES; 427 hrc->found = GNUNET_YES;
427 return GNUNET_YES; 428 return GNUNET_YES;
@@ -591,7 +592,17 @@ void
591GSF_mesh_query_cancel (struct GSF_MeshRequest *sr) 592GSF_mesh_query_cancel (struct GSF_MeshRequest *sr)
592{ 593{
593 struct MeshHandle *mh = sr->mh; 594 struct MeshHandle *mh = sr->mh;
595 GSF_MeshReplyProcessor p;
594 596
597 p = sr->proc;
598 sr->proc = NULL;
599 if (NULL != p)
600 {
601 /* signal failure / cancellation to callback */
602 p (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
603 GNUNET_TIME_UNIT_ZERO_ABS,
604 0, NULL);
605 }
595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
596 "Cancelled query for %s via mesh to %s\n", 607 "Cancelled query for %s via mesh to %s\n",
597 GNUNET_h2s (&sr->query), 608 GNUNET_h2s (&sr->query),
@@ -619,10 +630,10 @@ GSF_mesh_query_cancel (struct GSF_MeshRequest *sr)
619 * call the 'proc' continuation and release associated 630 * call the 'proc' continuation and release associated
620 * resources. 631 * resources.
621 * 632 *
622 * @param cls the 'struct MeshHandle' 633 * @param cls the `struct MeshHandle`
623 * @param key the key of the entry in the map (the query) 634 * @param key the key of the entry in the map (the query)
624 * @param value the 'struct GSF_MeshRequest' to clean up 635 * @param value the `struct GSF_MeshRequest` to clean up
625 * @return GNUNET_YES (continue to iterate) 636 * @return #GNUNET_YES (continue to iterate)
626 */ 637 */
627static int 638static int
628free_waiting_entry (void *cls, 639free_waiting_entry (void *cls,
@@ -631,9 +642,6 @@ free_waiting_entry (void *cls,
631{ 642{
632 struct GSF_MeshRequest *sr = value; 643 struct GSF_MeshRequest *sr = value;
633 644
634 sr->proc (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
635 GNUNET_TIME_UNIT_FOREVER_ABS,
636 0, NULL);
637 GSF_mesh_query_cancel (sr); 645 GSF_mesh_query_cancel (sr);
638 return GNUNET_YES; 646 return GNUNET_YES;
639} 647}
@@ -660,12 +668,7 @@ cleaner_cb (void *cls,
660 GNUNET_assert (channel == mh->channel); 668 GNUNET_assert (channel == mh->channel);
661 mh->channel = NULL; 669 mh->channel = NULL;
662 while (NULL != (sr = mh->pending_head)) 670 while (NULL != (sr = mh->pending_head))
663 {
664 sr->proc (sr->proc_cls, GNUNET_BLOCK_TYPE_ANY,
665 GNUNET_TIME_UNIT_FOREVER_ABS,
666 0, NULL);
667 GSF_mesh_query_cancel (sr); 671 GSF_mesh_query_cancel (sr);
668 }
669 GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map, 672 GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map,
670 &free_waiting_entry, 673 &free_waiting_entry,
671 mh); 674 mh);
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index ee71019bb..99c4056ae 100644
--- 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)
595 GSF_LocalLookupContinuation cont; 595 GSF_LocalLookupContinuation cont;
596 596
597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 597 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
598 "Cleaning up pending request for `%s'.\n", GNUNET_h2s (key)); 598 "Cleaning up pending request for `%s'.\n",
599 GNUNET_h2s (key));
600 if (NULL != pr->mesh_request)
601 {
602 pr->mesh_retry_count = MESH_RETRY_MAX;
603 GSF_mesh_query_cancel (pr->mesh_request);
604 pr->mesh_request = NULL;
605 }
599 if (NULL != (cont = pr->llc_cont)) 606 if (NULL != (cont = pr->llc_cont))
600 { 607 {
601 pr->llc_cont = NULL; 608 pr->llc_cont = NULL;
@@ -627,11 +634,6 @@ clean_request (void *cls, const struct GNUNET_HashCode * key, void *value)
627 GNUNET_DHT_get_stop (pr->gh); 634 GNUNET_DHT_get_stop (pr->gh);
628 pr->gh = NULL; 635 pr->gh = NULL;
629 } 636 }
630 if (NULL != pr->mesh_request)
631 {
632 GSF_mesh_query_cancel (pr->mesh_request);
633 pr->mesh_request = NULL;
634 }
635 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) 637 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
636 { 638 {
637 GNUNET_SCHEDULER_cancel (pr->warn_task); 639 GNUNET_SCHEDULER_cancel (pr->warn_task);
@@ -668,6 +670,12 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
668 * but do NOT remove from our data-structures, we still need it there 670 * but do NOT remove from our data-structures, we still need it there
669 * to prevent the request from looping */ 671 * to prevent the request from looping */
670 pr->rh = NULL; 672 pr->rh = NULL;
673 if (NULL != pr->mesh_request)
674 {
675 pr->mesh_retry_count = MESH_RETRY_MAX;
676 GSF_mesh_query_cancel (pr->mesh_request);
677 pr->mesh_request = NULL;
678 }
671 if (NULL != (cont = pr->llc_cont)) 679 if (NULL != (cont = pr->llc_cont))
672 { 680 {
673 pr->llc_cont = NULL; 681 pr->llc_cont = NULL;
@@ -684,11 +692,6 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, int full_cleanup)
684 GNUNET_DHT_get_stop (pr->gh); 692 GNUNET_DHT_get_stop (pr->gh);
685 pr->gh = NULL; 693 pr->gh = NULL;
686 } 694 }
687 if (NULL != pr->mesh_request)
688 {
689 GSF_mesh_query_cancel (pr->mesh_request);
690 pr->mesh_request = NULL;
691 }
692 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) 695 if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task)
693 { 696 {
694 GNUNET_SCHEDULER_cancel (pr->warn_task); 697 GNUNET_SCHEDULER_cancel (pr->warn_task);
@@ -1143,7 +1146,7 @@ GSF_dht_lookup_ (struct GSF_PendingRequest *pr)
1143 * @param cls the pending request struct 1146 * @param cls the pending request struct
1144 * @param type type of the block, ANY on error 1147 * @param type type of the block, ANY on error
1145 * @param expiration expiration time for the block 1148 * @param expiration expiration time for the block
1146 * @param data_size number of bytes in 'data', 0 on error 1149 * @param data_size number of bytes in @a data, 0 on error
1147 * @param data reply block data, NULL on error 1150 * @param data reply block data, NULL on error
1148 */ 1151 */
1149static void 1152static void
@@ -1162,11 +1165,11 @@ mesh_reply_proc (void *cls,
1162 { 1165 {
1163 GNUNET_break (NULL == data); 1166 GNUNET_break (NULL == data);
1164 GNUNET_break (0 == data_size); 1167 GNUNET_break (0 == data_size);
1165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1166 "Error retrieiving block via mesh\n");
1167 pr->mesh_retry_count++; 1168 pr->mesh_retry_count++;
1168 if (pr->mesh_retry_count >= MESH_RETRY_MAX) 1169 if (pr->mesh_retry_count >= MESH_RETRY_MAX)
1169 return; /* give up on mesh */ 1170 return; /* give up on mesh */
1171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1172 "Error retrieiving block via mesh\n");
1170 /* retry -- without delay, as this is non-anonymous 1173 /* retry -- without delay, as this is non-anonymous
1171 and mesh/mesh connect will take some time anyway */ 1174 and mesh/mesh connect will take some time anyway */
1172 pr->mesh_request = GSF_mesh_query (pr->public_data.target, 1175 pr->mesh_request = GSF_mesh_query (pr->public_data.target,