diff options
Diffstat (limited to 'src/fs/gnunet-service-fs_pr.c')
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 37865d913..4db3505dd 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -385,7 +385,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, | |||
385 | GNUNET_TIME_UNIT_FOREVER_ABS, | 385 | GNUNET_TIME_UNIT_FOREVER_ABS, |
386 | GNUNET_BLOCK_TYPE_ANY, | 386 | GNUNET_BLOCK_TYPE_ANY, |
387 | NULL, 0); | 387 | NULL, 0); |
388 | GSF_pending_request_cancel_ (dpr); | 388 | GSF_pending_request_cancel_ (dpr, GNUNET_YES); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | GNUNET_STATISTICS_update (GSF_stats, | 391 | GNUNET_STATISTICS_update (GSF_stats, |
@@ -410,6 +410,33 @@ GSF_pending_request_get_data_ (struct GSF_PendingRequest *pr) | |||
410 | 410 | ||
411 | 411 | ||
412 | /** | 412 | /** |
413 | * Test if two pending requests are compatible (would generate | ||
414 | * the same query modulo filters and should thus be processed | ||
415 | * jointly). | ||
416 | * | ||
417 | * @param pra a pending request | ||
418 | * @param pra another pending request | ||
419 | * @return GNUNET_OK if the requests are compatible | ||
420 | */ | ||
421 | int | ||
422 | GSF_pending_request_is_compatible_ (struct GSF_PendingRequest *pra, | ||
423 | struct GSF_PendingRequest *prb) | ||
424 | { | ||
425 | if ( (pra->public_data.type != prb->public_data.type) || | ||
426 | (0 != memcmp (&pra->public_data.query, | ||
427 | &prb->public_data.query, | ||
428 | sizeof (GNUNET_HashCode))) || | ||
429 | ( (pra->public_data.type == GNUNET_BLOCK_TYPE_FS_SBLOCK) && | ||
430 | (0 != memcmp (&pra->public_data.namespace, | ||
431 | &prb->public_data.namespace, | ||
432 | sizeof (GNUNET_HashCode))) ) ) | ||
433 | return GNUNET_NO; | ||
434 | return GNUNET_OK; | ||
435 | } | ||
436 | |||
437 | |||
438 | |||
439 | /** | ||
413 | * Update a given pending request with additional replies | 440 | * Update a given pending request with additional replies |
414 | * that have been seen. | 441 | * that have been seen. |
415 | * | 442 | * |
@@ -646,12 +673,47 @@ clean_request (void *cls, | |||
646 | * Explicitly cancel a pending request. | 673 | * Explicitly cancel a pending request. |
647 | * | 674 | * |
648 | * @param pr request to cancel | 675 | * @param pr request to cancel |
676 | * @param full_cleanup fully purge the request | ||
649 | */ | 677 | */ |
650 | void | 678 | void |
651 | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr) | 679 | GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr, |
680 | int full_cleanup) | ||
652 | { | 681 | { |
682 | GSF_LocalLookupContinuation cont; | ||
683 | |||
653 | if (NULL == pr_map) | 684 | if (NULL == pr_map) |
654 | return; /* already cleaned up! */ | 685 | return; /* already cleaned up! */ |
686 | if (GNUNET_YES != full_cleanup) | ||
687 | { | ||
688 | /* make request inactive (we're no longer interested in more results), | ||
689 | but do NOT remove from our data-structures, we still need it there | ||
690 | to prevent the request from looping */ | ||
691 | pr->rh = NULL; | ||
692 | if (NULL != (cont = pr->llc_cont)) | ||
693 | { | ||
694 | pr->llc_cont = NULL; | ||
695 | cont (pr->llc_cont_cls, | ||
696 | pr, | ||
697 | pr->local_result); | ||
698 | } | ||
699 | GSF_plan_notify_request_done_ (pr); | ||
700 | if (NULL != pr->qe) | ||
701 | { | ||
702 | GNUNET_DATASTORE_cancel (pr->qe); | ||
703 | pr->qe = NULL; | ||
704 | } | ||
705 | if (NULL != pr->gh) | ||
706 | { | ||
707 | GNUNET_DHT_get_stop (pr->gh); | ||
708 | pr->gh = NULL; | ||
709 | } | ||
710 | if (GNUNET_SCHEDULER_NO_TASK != pr->warn_task) | ||
711 | { | ||
712 | GNUNET_SCHEDULER_cancel (pr->warn_task); | ||
713 | pr->warn_task = GNUNET_SCHEDULER_NO_TASK; | ||
714 | } | ||
715 | return; | ||
716 | } | ||
655 | GNUNET_assert (GNUNET_YES == | 717 | GNUNET_assert (GNUNET_YES == |
656 | clean_request (NULL, &pr->public_data.query, pr)); | 718 | clean_request (NULL, &pr->public_data.query, pr)); |
657 | } | 719 | } |
@@ -763,6 +825,8 @@ process_reply (void *cls, | |||
763 | struct GSF_PendingRequest *pr = value; | 825 | struct GSF_PendingRequest *pr = value; |
764 | GNUNET_HashCode chash; | 826 | GNUNET_HashCode chash; |
765 | 827 | ||
828 | if (NULL == pr->rh) | ||
829 | return GNUNET_YES; | ||
766 | #if DEBUG_FS | 830 | #if DEBUG_FS |
767 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 831 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
768 | "Matched result (type %u) for query `%s' with pending request\n", | 832 | "Matched result (type %u) for query `%s' with pending request\n", |