aboutsummaryrefslogtreecommitdiff
path: root/src/peerstore/peerstore_api.c
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-12-19 02:06:13 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-12-19 02:06:13 +0000
commit06ff4d4f274ae5269c9b403e1bbd0b93a96ff6d8 (patch)
treedebc52bb193af6f8c812ac6de20f2b93b6f9cf14 /src/peerstore/peerstore_api.c
parent42c34f9b26b6b0222a10f61850af73914ce5a359 (diff)
downloadgnunet-06ff4d4f274ae5269c9b403e1bbd0b93a96ff6d8.tar.gz
gnunet-06ff4d4f274ae5269c9b403e1bbd0b93a96ff6d8.zip
Diffstat (limited to 'src/peerstore/peerstore_api.c')
-rw-r--r--src/peerstore/peerstore_api.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/peerstore/peerstore_api.c b/src/peerstore/peerstore_api.c
index 52b1b22ca..8ef04604f 100644
--- a/src/peerstore/peerstore_api.c
+++ b/src/peerstore/peerstore_api.c
@@ -437,6 +437,7 @@ static void
437reconnect (struct GNUNET_PEERSTORE_Handle *h) 437reconnect (struct GNUNET_PEERSTORE_Handle *h)
438{ 438{
439 struct GNUNET_PEERSTORE_IterateContext *ic; 439 struct GNUNET_PEERSTORE_IterateContext *ic;
440 struct GNUNET_PEERSTORE_IterateContext *ic_tmp;
440 GNUNET_PEERSTORE_Processor icb; 441 GNUNET_PEERSTORE_Processor icb;
441 void *icb_cls; 442 void *icb_cls;
442 struct GNUNET_PEERSTORE_StoreContext *sc; 443 struct GNUNET_PEERSTORE_StoreContext *sc;
@@ -450,32 +451,17 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
450 sc->ev = NULL; 451 sc->ev = NULL;
451 } 452 }
452 } 453 }
453 if (NULL != h->mq) 454 ic = h->iterate_head;
454 { 455 while (NULL != ic)
455 GNUNET_MQ_destroy (h->mq);
456 h->mq = NULL;
457 }
458 if (NULL != h->client)
459 {
460 GNUNET_CLIENT_disconnect (h->client);
461 h->client = NULL;
462 }
463 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
464 GNUNET_assert (NULL != h->client);
465 h->mq =
466 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
467 &handle_client_error, h);
468 LOG (GNUNET_ERROR_TYPE_DEBUG,
469 "Resending pending requests after reconnect.\n");
470 if (NULL != h->watches)
471 GNUNET_CONTAINER_multihashmap_iterate (h->watches, &rewatch_it, h);
472 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
473 { 456 {
474 if (GNUNET_YES == ic->iterating) 457 if (GNUNET_YES == ic->iterating)
475 { 458 {
476 icb = ic->callback; 459 icb = ic->callback;
477 icb_cls = ic->callback_cls; 460 icb_cls = ic->callback_cls;
478 GNUNET_PEERSTORE_iterate_cancel (ic); 461 ic->iterating = GNUNET_NO;
462 ic_tmp = ic;
463 ic = ic->next;
464 GNUNET_PEERSTORE_iterate_cancel (ic_tmp);
479 if (NULL != icb) 465 if (NULL != icb)
480 icb (icb_cls, NULL, _("Iteration canceled due to reconnection.")); 466 icb (icb_cls, NULL, _("Iteration canceled due to reconnection."));
481 } 467 }
@@ -491,16 +477,39 @@ reconnect (struct GNUNET_PEERSTORE_Handle *h)
491 GNUNET_MQ_send_cancel (ic->ev); 477 GNUNET_MQ_send_cancel (ic->ev);
492 ic->ev = NULL; 478 ic->ev = NULL;
493 } 479 }
494 ic->ev = 480 ic = ic->next;
495 PEERSTORE_create_record_mq_envelope (ic->sub_system, &ic->peer,
496 ic->key, NULL, 0, NULL, 0,
497 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
498 GNUNET_MQ_notify_sent (ic->ev, &iterate_request_sent, ic);
499 GNUNET_MQ_send (h->mq, ic->ev);
500 ic->timeout_task =
501 GNUNET_SCHEDULER_add_delayed (ic->timeout, &iterate_timeout, ic);
502 } 481 }
503 } 482 }
483 if (NULL != h->mq)
484 {
485 GNUNET_MQ_destroy (h->mq);
486 h->mq = NULL;
487 }
488 if (NULL != h->client)
489 {
490 GNUNET_CLIENT_disconnect (h->client);
491 h->client = NULL;
492 }
493 h->client = GNUNET_CLIENT_connect ("peerstore", h->cfg);
494 GNUNET_assert (NULL != h->client);
495 h->mq =
496 GNUNET_MQ_queue_for_connection_client (h->client, mq_handlers,
497 &handle_client_error, h);
498 LOG (GNUNET_ERROR_TYPE_DEBUG,
499 "Resending pending requests after reconnect.\n");
500 if (NULL != h->watches)
501 GNUNET_CONTAINER_multihashmap_iterate (h->watches, &rewatch_it, h);
502 for (ic = h->iterate_head; NULL != ic; ic = ic->next)
503 {
504 ic->ev =
505 PEERSTORE_create_record_mq_envelope (ic->sub_system, &ic->peer, ic->key,
506 NULL, 0, NULL, 0,
507 GNUNET_MESSAGE_TYPE_PEERSTORE_ITERATE);
508 GNUNET_MQ_notify_sent (ic->ev, &iterate_request_sent, ic);
509 GNUNET_MQ_send (h->mq, ic->ev);
510 ic->timeout_task =
511 GNUNET_SCHEDULER_add_delayed (ic->timeout, &iterate_timeout, ic);
512 }
504 for (sc = h->store_head; NULL != sc; sc = sc->next) 513 for (sc = h->store_head; NULL != sc; sc = sc->next)
505 { 514 {
506 sc->ev = 515 sc->ev =