aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/peerinfo_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-08 13:02:55 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-08 13:02:55 +0000
commit89bdc195517c6528e278a53b8c0b19a80950ff52 (patch)
tree72e41fb9df9cdc6c93d7cc4a9e0c866797b1041f /src/peerinfo/peerinfo_api.c
parent479688c1563fe04c51446cfc1b1fb3c1808c62cf (diff)
downloadgnunet-89bdc195517c6528e278a53b8c0b19a80950ff52.tar.gz
gnunet-89bdc195517c6528e278a53b8c0b19a80950ff52.zip
-fixing #2406
Diffstat (limited to 'src/peerinfo/peerinfo_api.c')
-rw-r--r--src/peerinfo/peerinfo_api.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index c13224e83..62e20b266 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -186,7 +186,7 @@ struct GNUNET_PEERINFO_Handle
186 * Set to GNUNET_YES if we are currently receiving replies from the 186 * Set to GNUNET_YES if we are currently receiving replies from the
187 * service. 187 * service.
188 */ 188 */
189 int in_receive; 189 int request_transmitted;
190 190
191}; 191};
192 192
@@ -227,8 +227,8 @@ GNUNET_PEERINFO_disconnect (struct GNUNET_PEERINFO_Handle *h)
227 227
228 while (NULL != (ic = h->ic_head)) 228 while (NULL != (ic = h->ic_head))
229 { 229 {
230 GNUNET_break (GNUNET_YES == ic->in_receive); 230 GNUNET_break (GNUNET_YES == ic->request_transmitted);
231 ic->in_receive = GNUNET_NO; 231 ic->request_transmitted = GNUNET_NO;
232 GNUNET_PEERINFO_iterate_cancel (ic); 232 GNUNET_PEERINFO_iterate_cancel (ic);
233 } 233 }
234 while (NULL != (ac = h->ac_head)) 234 while (NULL != (ac = h->ac_head))
@@ -492,7 +492,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
492 492
493 GNUNET_assert (NULL != ic); 493 GNUNET_assert (NULL != ic);
494 h->in_receive = GNUNET_NO; 494 h->in_receive = GNUNET_NO;
495 ic->in_receive = GNUNET_NO; 495 ic->request_transmitted = GNUNET_NO;
496 cb = ic->callback; 496 cb = ic->callback;
497 cb_cls = ic->callback_cls; 497 cb_cls = ic->callback_cls;
498 if (NULL == msg) 498 if (NULL == msg)
@@ -513,6 +513,12 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
513 "Received end of list of peers from `%s' service\n", "PEERINFO"); 513 "Received end of list of peers from `%s' service\n", "PEERINFO");
514 GNUNET_PEERINFO_iterate_cancel (ic); 514 GNUNET_PEERINFO_iterate_cancel (ic);
515 trigger_transmit (h); 515 trigger_transmit (h);
516 if (GNUNET_NO == h->in_receive)
517 {
518 h->in_receive = GNUNET_YES;
519 GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h,
520 GNUNET_TIME_absolute_get_remaining (ic->timeout));
521 }
516 if (NULL != cb) 522 if (NULL != cb)
517 cb (cb_cls, NULL, NULL, NULL); 523 cb (cb_cls, NULL, NULL, NULL);
518 return; 524 return;
@@ -594,8 +600,8 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
594 "Received %u bytes of `%s' information about peer `%s' from `%s' service\n", 600 "Received %u bytes of `%s' information about peer `%s' from `%s' service\n",
595 (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), "HELLO", 601 (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello), "HELLO",
596 GNUNET_i2s (&im->peer), "PEERINFO"); 602 GNUNET_i2s (&im->peer), "PEERINFO");
603 ic->request_transmitted = GNUNET_YES;
597 h->in_receive = GNUNET_YES; 604 h->in_receive = GNUNET_YES;
598 ic->in_receive = GNUNET_YES;
599 GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h, 605 GNUNET_CLIENT_receive (h->client, &peerinfo_handler, h,
600 GNUNET_TIME_absolute_get_remaining (ic->timeout)); 606 GNUNET_TIME_absolute_get_remaining (ic->timeout));
601 if (NULL != cb) 607 if (NULL != cb)
@@ -631,7 +637,7 @@ iterator_start_receive (void *cls, const char *emsg)
631 } 637 }
632 LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for response from `%s' service.\n", 638 LOG (GNUNET_ERROR_TYPE_DEBUG, "Waiting for response from `%s' service.\n",
633 "PEERINFO"); 639 "PEERINFO");
634 ic->in_receive = GNUNET_YES; 640 ic->request_transmitted = GNUNET_YES;
635 if (GNUNET_NO == h->in_receive) 641 if (GNUNET_NO == h->in_receive)
636 { 642 {
637 h->in_receive = GNUNET_YES; 643 h->in_receive = GNUNET_YES;
@@ -755,7 +761,7 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic)
755 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; 761 ic->timeout_task = GNUNET_SCHEDULER_NO_TASK;
756 } 762 }
757 ic->callback = NULL; 763 ic->callback = NULL;
758 if (GNUNET_YES == ic->in_receive) 764 if (GNUNET_YES == ic->request_transmitted)
759 return; /* need to finish processing */ 765 return; /* need to finish processing */
760 GNUNET_CONTAINER_DLL_remove (h->ic_head, 766 GNUNET_CONTAINER_DLL_remove (h->ic_head,
761 h->ic_tail, 767 h->ic_tail,