aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-11-22 21:10:36 +0000
committerChristian Grothoff <christian@grothoff.org>2010-11-22 21:10:36 +0000
commit737a292594cd51fab8d1b6e20bab81b030472f75 (patch)
tree0fecf1ecb0f517c1e2c2fdb74d9705317f76524c
parent50d2b91a6e689d617813aaeefe170465075bae42 (diff)
downloadgnunet-737a292594cd51fab8d1b6e20bab81b030472f75.tar.gz
gnunet-737a292594cd51fab8d1b6e20bab81b030472f75.zip
fixing various issues Nate had: ready queue simply must be purged on reconnect
-rw-r--r--src/core/core_api.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index 3b7e954ce..c767507cb 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -463,6 +463,7 @@ static void
463reconnect_later (struct GNUNET_CORE_Handle *h) 463reconnect_later (struct GNUNET_CORE_Handle *h)
464{ 464{
465 struct ControlMessage *cm; 465 struct ControlMessage *cm;
466 struct PeerRecord *pr;
466 467
467 while (NULL != (cm = h->pending_head)) 468 while (NULL != (cm = h->pending_head))
468 { 469 {
@@ -484,6 +485,11 @@ reconnect_later (struct GNUNET_CORE_Handle *h)
484 &disconnect_and_free_peer_entry, 485 &disconnect_and_free_peer_entry,
485 h); 486 h);
486 } 487 }
488 while (NULL != (pr = h->ready_peer_head))
489 GNUNET_CONTAINER_DLL_remove (h->ready_peer_head,
490 h->ready_peer_tail,
491 pr);
492
487 GNUNET_assert (h->pending_head == NULL); 493 GNUNET_assert (h->pending_head == NULL);
488 h->currently_down = GNUNET_YES; 494 h->currently_down = GNUNET_YES;
489 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); 495 GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK);
@@ -664,12 +670,7 @@ transmit_message (void *cls,
664 /* now check for 'ready' P2P messages */ 670 /* now check for 'ready' P2P messages */
665 if (NULL != (pr = h->ready_peer_head)) 671 if (NULL != (pr = h->ready_peer_head))
666 { 672 {
667 /* FIXME: If a reconnect_later call happened, this can be NULL! */ 673 GNUNET_assert (pr->pending_head != NULL);
668 if (pr->pending_head == NULL)
669 {
670 GNUNET_break(0);
671 return 0;
672 }
673 th = pr->pending_head; 674 th = pr->pending_head;
674 if (size < th->msize + sizeof (struct SendMessage)) 675 if (size < th->msize + sizeof (struct SendMessage))
675 { 676 {
@@ -769,7 +770,7 @@ trigger_next_request (struct GNUNET_CORE_Handle *h,
769 } 770 }
770 if (h->pending_head != NULL) 771 if (h->pending_head != NULL)
771 msize = ntohs (((struct GNUNET_MessageHeader*) &h->pending_head[1])->size); 772 msize = ntohs (((struct GNUNET_MessageHeader*) &h->pending_head[1])->size);
772 else if ((h->ready_peer_head != NULL) && (h->ready_peer_head->pending_head != NULL)) /* FIXME: h->ready_peer_head->pending_head check necessary? */ 773 else if (h->ready_peer_head != NULL)
773 msize = h->ready_peer_head->pending_head->msize + sizeof (struct SendMessage); 774 msize = h->ready_peer_head->pending_head->msize + sizeof (struct SendMessage);
774 else 775 else
775 { 776 {
@@ -1133,7 +1134,7 @@ main_notify_handler (void *cls,
1133#endif 1134#endif
1134 if (pr->pending_head == NULL) 1135 if (pr->pending_head == NULL)
1135 { 1136 {
1136 /* request must have been cancelled between the origional request 1137 /* request must have been cancelled between the original request
1137 and the response from core, ignore core's readiness */ 1138 and the response from core, ignore core's readiness */
1138 return; 1139 return;
1139 } 1140 }
@@ -1518,21 +1519,13 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
1518 1519
1519 /* Order entries by deadline, but SKIP 'HEAD' if 1520 /* Order entries by deadline, but SKIP 'HEAD' if
1520 we're in the 'ready_peer_*' DLL */ 1521 we're in the 'ready_peer_*' DLL */
1521 /* FIXME: again, pr->pending_head is NULL after a reconnect_later call */
1522 pos = pr->pending_head; 1522 pos = pr->pending_head;
1523 if (pr->pending_head != NULL) 1523 if ( (pr->prev != NULL) ||
1524 { 1524 (pr->next != NULL) ||
1525 if ( (pr->prev != NULL) || 1525 (pr == handle->ready_peer_head) )
1526 (pr->next != NULL) ||
1527 (pr == handle->ready_peer_head) )
1528 {
1529 GNUNET_assert (pos != NULL);
1530 pos = pos->next; /* skip head */
1531 }
1532 }
1533 else
1534 { 1526 {
1535 GNUNET_break(0); 1527 GNUNET_assert (pos != NULL);
1528 pos = pos->next; /* skip head */
1536 } 1529 }
1537 1530
1538 /* insertion sort */ 1531 /* insertion sort */