diff options
Diffstat (limited to 'src/peerstore')
-rw-r--r-- | src/peerstore/peerstore_api.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c index c7bca2e8a..0a087cb70 100644 --- a/src/peerstore/peerstore_api.c +++ b/src/peerstore/peerstore_api.c | |||
@@ -391,15 +391,21 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h) | |||
391 | struct GNUNET_PEERSTORE_StoreContext *sc; | 391 | struct GNUNET_PEERSTORE_StoreContext *sc; |
392 | struct GNUNET_MQ_Envelope *ev; | 392 | struct GNUNET_MQ_Envelope *ev; |
393 | 393 | ||
394 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting...\n"); | 394 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
395 | "Reconnecting...\n"); | ||
395 | for (ic = h->iterate_head; NULL != ic; ic = next) | 396 | for (ic = h->iterate_head; NULL != ic; ic = next) |
396 | { | 397 | { |
397 | next = ic->next; | 398 | next = ic->next; |
398 | icb = ic->callback; | 399 | if (GNUNET_YES == ic->iterating) |
399 | icb_cls = ic->callback_cls; | 400 | { |
400 | GNUNET_PEERSTORE_iterate_cancel (ic); | 401 | icb = ic->callback; |
401 | if (NULL != icb) | 402 | icb_cls = ic->callback_cls; |
402 | icb (icb_cls, NULL, _("Iteration canceled due to reconnection.")); | 403 | GNUNET_PEERSTORE_iterate_cancel (ic); |
404 | if (NULL != icb) | ||
405 | icb (icb_cls, | ||
406 | NULL, | ||
407 | "Iteration canceled due to reconnection"); | ||
408 | } | ||
403 | } | 409 | } |
404 | if (NULL != h->mq) | 410 | if (NULL != h->mq) |
405 | { | 411 | { |
@@ -530,12 +536,11 @@ GNUNET_PEERSTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
530 | * @param sync_first send any pending STORE requests before disconnecting | 536 | * @param sync_first send any pending STORE requests before disconnecting |
531 | */ | 537 | */ |
532 | void | 538 | void |
533 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first) | 539 | GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, |
540 | int sync_first) | ||
534 | { | 541 | { |
535 | struct GNUNET_PEERSTORE_IterateContext *ic; | 542 | struct GNUNET_PEERSTORE_IterateContext *ic; |
536 | struct GNUNET_PEERSTORE_IterateContext *ic_iter; | ||
537 | struct GNUNET_PEERSTORE_StoreContext *sc; | 543 | struct GNUNET_PEERSTORE_StoreContext *sc; |
538 | struct GNUNET_PEERSTORE_StoreContext *sc_iter; | ||
539 | 544 | ||
540 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n"); | 545 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting.\n"); |
541 | if (NULL != h->watches) | 546 | if (NULL != h->watches) |
@@ -544,12 +549,9 @@ GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first) | |||
544 | GNUNET_CONTAINER_multihashmap_destroy (h->watches); | 549 | GNUNET_CONTAINER_multihashmap_destroy (h->watches); |
545 | h->watches = NULL; | 550 | h->watches = NULL; |
546 | } | 551 | } |
547 | ic_iter = h->iterate_head; | 552 | while (NULL != (ic = h->iterate_head)) |
548 | while (NULL != ic_iter) | ||
549 | { | 553 | { |
550 | GNUNET_break (0); | 554 | GNUNET_break (0); |
551 | ic = ic_iter; | ||
552 | ic_iter = ic_iter->next; | ||
553 | GNUNET_PEERSTORE_iterate_cancel (ic); | 555 | GNUNET_PEERSTORE_iterate_cancel (ic); |
554 | } | 556 | } |
555 | if (NULL != h->store_head) | 557 | if (NULL != h->store_head) |
@@ -561,13 +563,8 @@ GNUNET_PEERSTORE_disconnect (struct GNUNET_PEERSTORE_Handle *h, int sync_first) | |||
561 | h->disconnecting = GNUNET_YES; | 563 | h->disconnecting = GNUNET_YES; |
562 | return; | 564 | return; |
563 | } | 565 | } |
564 | sc_iter = h->store_head; | 566 | while (NULL != (sc = h->store_head)) |
565 | while (NULL != sc_iter) | ||
566 | { | ||
567 | sc = sc_iter; | ||
568 | sc_iter = sc_iter->next; | ||
569 | GNUNET_PEERSTORE_store_cancel (sc); | 567 | GNUNET_PEERSTORE_store_cancel (sc); |
570 | } | ||
571 | } | 568 | } |
572 | do_disconnect (h); | 569 | do_disconnect (h); |
573 | } | 570 | } |
@@ -736,7 +733,9 @@ GNUNET_PEERSTORE_iterate_cancel (struct GNUNET_PEERSTORE_IterateContext *ic) | |||
736 | } | 733 | } |
737 | if (GNUNET_NO == ic->iterating) | 734 | if (GNUNET_NO == ic->iterating) |
738 | { | 735 | { |
739 | GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, ic->h->iterate_tail, ic); | 736 | GNUNET_CONTAINER_DLL_remove (ic->h->iterate_head, |
737 | ic->h->iterate_tail, | ||
738 | ic); | ||
740 | GNUNET_free (ic->sub_system); | 739 | GNUNET_free (ic->sub_system); |
741 | if (NULL != ic->key) | 740 | if (NULL != ic->key) |
742 | GNUNET_free (ic->key); | 741 | GNUNET_free (ic->key); |