diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-16 22:07:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-16 22:07:27 +0000 |
commit | 102e551140236377da16cf85c0aed8effeac9f78 (patch) | |
tree | 5263397cf5e346a1f31daee384e197b8cbbe67a9 /src/peerstore/peerstore_api.c | |
parent | 82465941d94d3d19322da63f7e2a68da9d2422c8 (diff) | |
download | gnunet-102e551140236377da16cf85c0aed8effeac9f78.tar.gz gnunet-102e551140236377da16cf85c0aed8effeac9f78.zip |
-must notify client on timeout
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r-- | src/peerstore/peerstore_api.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index 122f49c59..a8d372884 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -480,13 +480,16 @@ GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first) | |||
480 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n"); | 480 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n"); |
481 | if (NULL != h->watches) | 481 | if (NULL != h->watches) |
482 | { | 482 | { |
483 | GNUNET_CONTAINER_multihashmap_iterate (h->watches, &destroy_watch, NULL); | 483 | GNUNET_CONTAINER_multihashmap_iterate (h->watches, |
484 | &destroy_watch, | ||
485 | NULL); | ||
484 | GNUNET_CONTAINER_multihashmap_destroy (h->watches); | 486 | GNUNET_CONTAINER_multihashmap_destroy (h->watches); |
485 | h->watches = NULL; | 487 | h->watches = NULL; |
486 | } | 488 | } |
487 | ic_iter = h->iterate_head; | 489 | ic_iter = h->iterate_head; |
488 | while (NULL != ic_iter) | 490 | while (NULL != ic_iter) |
489 | { | 491 | { |
492 | GNUNET_break (0); | ||
490 | ic = ic_iter; | 493 | ic = ic_iter; |
491 | ic_iter = ic_iter->next; | 494 | ic_iter = ic_iter->next; |
492 | GNUNET_PEERSTORE_iterate_cancel (ic); | 495 | GNUNET_PEERSTORE_iterate_cancel (ic); |
@@ -677,14 +680,15 @@ handle_iterate_result (void *cls, const struct GNUNET_MessageHeader *msg) | |||
677 | /** | 680 | /** |
678 | * Callback after MQ envelope is sent | 681 | * Callback after MQ envelope is sent |
679 | * | 682 | * |
680 | * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *' | 683 | * @param cls a `struct GNUNET_PEERSTORE_IterateContext *` |
681 | */ | 684 | */ |
682 | static void | 685 | static void |
683 | iterate_request_sent (void *cls) | 686 | iterate_request_sent (void *cls) |
684 | { | 687 | { |
685 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; | 688 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; |
686 | 689 | ||
687 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Iterate request sent to service.\n"); | 690 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
691 | "Iterate request sent to service.\n"); | ||
688 | ic->iterating = GNUNET_YES; | 692 | ic->iterating = GNUNET_YES; |
689 | ic->ev = NULL; | 693 | ic->ev = NULL; |
690 | } | 694 | } |
@@ -693,16 +697,25 @@ iterate_request_sent (void *cls) | |||
693 | /** | 697 | /** |
694 | * Called when the iterate request is timedout | 698 | * Called when the iterate request is timedout |
695 | * | 699 | * |
696 | * @param cls a 'struct GNUNET_PEERSTORE_IterateContext *' | 700 | * @param cls a `struct GNUNET_PEERSTORE_IterateContext *` |
697 | * @param tc Scheduler task context (unused) | 701 | * @param tc Scheduler task context (unused) |
698 | */ | 702 | */ |
699 | static void | 703 | static void |
700 | iterate_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 704 | iterate_timeout (void *cls, |
705 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
701 | { | 706 | { |
702 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; | 707 | struct GNUNET_PEERSTORE_IterateContext *ic = cls; |
708 | GNUNET_PEERSTORE_Processor callback; | ||
709 | void *callback_cls; | ||
703 | 710 | ||
704 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 711 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
712 | callback = ic->callback; | ||
713 | callback_cls = ic->callback_cls; | ||
705 | GNUNET_PEERSTORE_iterate_cancel (ic); | 714 | GNUNET_PEERSTORE_iterate_cancel (ic); |
715 | if (NULL != callback) | ||
716 | callback (callback_cls, | ||
717 | NULL, | ||
718 | _("timeout")); | ||
706 | } | 719 | } |
707 | 720 | ||
708 | 721 | ||
@@ -727,7 +740,9 @@ GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic) | |||
727 | GNUNET_MQ_send_cancel (ic->ev); | 740 | GNUNET_MQ_send_cancel (ic->ev); |
728 | ic->ev = NULL; | 741 | ic->ev = NULL; |
729 | } | 742 | } |
730 | GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, ic->h->iterate_tail, ic); | 743 | GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, |
744 | ic->h->iterate_tail, | ||
745 | ic); | ||
731 | GNUNET_free (ic); | 746 | GNUNET_free (ic); |
732 | } | 747 | } |
733 | else | 748 | else |
@@ -751,7 +766,8 @@ struct GNUNET_PEERSTORE_IterateContext * | |||
751 | GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h, | 766 | GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h, |
752 | const char *sub_system, | 767 | const char *sub_system, |
753 | const struct GNUNET_PeerIdentity *peer, | 768 | const struct GNUNET_PeerIdentity *peer, |
754 | const char *key, struct GNUNET_TIME_Relative timeout, | 769 | const char *key, |
770 | struct GNUNET_TIME_Relative timeout, | ||
755 | GNUNET_PEERSTORE_Processor callback, | 771 | GNUNET_PEERSTORE_Processor callback, |
756 | void *callback_cls) | 772 | void *callback_cls) |
757 | { | 773 | { |
@@ -768,7 +784,9 @@ GNUNET_PEERSTORE_iterate (struct GNUNET_PEERSTORE_Handle *h, | |||
768 | ic->ev = ev; | 784 | ic->ev = ev; |
769 | ic->h = h; | 785 | ic->h = h; |
770 | ic->iterating = GNUNET_NO; | 786 | ic->iterating = GNUNET_NO; |
771 | GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, h->iterate_tail, ic); | 787 | GNUNET_CONTAINER_DLL_insert_tail (h->iterate_head, |
788 | h->iterate_tail, | ||
789 | ic); | ||
772 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 790 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
773 | "Sending an iterate request for sub system `%s'\n", sub_system); | 791 | "Sending an iterate request for sub system `%s'\n", sub_system); |
774 | GNUNET_MQ_notify_sent (ev, &iterate_request_sent, ic); | 792 | GNUNET_MQ_notify_sent (ev, &iterate_request_sent, ic); |