aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-11 13:42:22 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-11 13:42:22 +0000
commitc5e75397db3b88d41f1bd61b6422ddc74993f797 (patch)
tree8212ff5e517c80cdcf43b5009367d4ee53242127 /src
parent37af1963382a5b7d32f390f6a169e089babb1dee (diff)
downloadgnunet-c5e75397db3b88d41f1bd61b6422ddc74993f797.tar.gz
gnunet-c5e75397db3b88d41f1bd61b6422ddc74993f797.zip
do not call receive before sending first message
Diffstat (limited to 'src')
-rw-r--r--src/ats/ats_api_performance.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index d29494605..a4166be10 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -241,6 +241,11 @@ struct GNUNET_ATS_PerformanceHandle
241 * Request multiplexing 241 * Request multiplexing
242 */ 242 */
243 uint32_t id; 243 uint32_t id;
244
245 /**
246 * Is the receive loop active?
247 */
248 int in_receive;
244}; 249};
245 250
246/** 251/**
@@ -323,6 +328,14 @@ transmit_message_to_ats (void *cls,
323 GNUNET_free(p); 328 GNUNET_free(p);
324 } 329 }
325 do_transmit (ph); 330 do_transmit (ph);
331 if (GNUNET_NO == ph->in_receive)
332 {
333 ph->in_receive = GNUNET_YES;
334 GNUNET_CLIENT_receive (ph->client,
335 &process_ats_message,
336 ph,
337 GNUNET_TIME_UNIT_FOREVER_REL);
338 }
326 return ret; 339 return ret;
327} 340}
328 341
@@ -469,7 +482,7 @@ process_rr_message (struct GNUNET_ATS_PerformanceHandle *ph,
469 482
470 483
471/** 484/**
472 * We received a reservation result message. Validate and process it. 485 * We received a PeerInformationMessage. Validate and process it.
473 * 486 *
474 * @param ph our context with the callback 487 * @param ph our context with the callback
475 * @param msg the message 488 * @param msg the message
@@ -593,18 +606,27 @@ process_ats_message (void *cls,
593 { 606 {
594 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION: 607 case GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION:
595 if (GNUNET_OK != process_pi_message (ph, msg)) 608 if (GNUNET_OK != process_pi_message (ph, msg))
609 {
610 GNUNET_break (0);
596 goto reconnect; 611 goto reconnect;
612 }
597 break; 613 break;
598 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT: 614 case GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT:
599 if (GNUNET_OK != process_rr_message (ph, msg)) 615 if (GNUNET_OK != process_rr_message (ph, msg))
616 {
617 GNUNET_break (0);
600 goto reconnect; 618 goto reconnect;
619 }
601 break; 620 break;
602 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE: 621 case GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE:
603 if (GNUNET_OK != process_ar_message (ph, msg)) 622 if (GNUNET_OK != process_ar_message (ph, msg))
623 {
624 GNUNET_break (0);
604 goto reconnect; 625 goto reconnect;
626 }
605 break; 627 break;
606 default: 628 default:
607 GNUNET_break(0); 629 GNUNET_break (0);
608 goto reconnect; 630 goto reconnect;
609 } 631 }
610 ph->backoff = GNUNET_TIME_UNIT_ZERO; 632 ph->backoff = GNUNET_TIME_UNIT_ZERO;
@@ -622,17 +644,21 @@ process_ats_message (void *cls,
622 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th); 644 GNUNET_CLIENT_notify_transmit_ready_cancel (ph->th);
623 ph->th = NULL; 645 ph->th = NULL;
624 } 646 }
625 GNUNET_CLIENT_disconnect (ph->client); 647 if (NULL != ph->client)
626 ph->client = NULL;
627 if (NULL != ph->addr_info_cb)
628 { 648 {
629 /* Indicate reconnect */ 649 GNUNET_CLIENT_disconnect (ph->client);
630 ph->addr_info_cb (ph->addr_info_cb_cls, 650 ph->client = NULL;
631 NULL, 651 ph->in_receive = GNUNET_NO;
632 GNUNET_NO, 652 if (NULL != ph->addr_info_cb)
633 GNUNET_BANDWIDTH_value_init (0), 653 {
634 GNUNET_BANDWIDTH_value_init (0), 654 /* Indicate reconnect */
635 NULL); 655 ph->addr_info_cb (ph->addr_info_cb_cls,
656 NULL,
657 GNUNET_NO,
658 GNUNET_BANDWIDTH_value_init (0),
659 GNUNET_BANDWIDTH_value_init (0),
660 NULL);
661 }
636 } 662 }
637 ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff); 663 ph->backoff = GNUNET_TIME_STD_BACKOFF (ph->backoff);
638 ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff, 664 ph->task = GNUNET_SCHEDULER_add_delayed (ph->backoff,
@@ -656,10 +682,6 @@ reconnect (struct GNUNET_ATS_PerformanceHandle *ph)
656 ph->client = GNUNET_CLIENT_connect ("ats", 682 ph->client = GNUNET_CLIENT_connect ("ats",
657 ph->cfg); 683 ph->cfg);
658 GNUNET_assert (NULL != ph->client); 684 GNUNET_assert (NULL != ph->client);
659 GNUNET_CLIENT_receive (ph->client,
660 &process_ats_message,
661 ph,
662 GNUNET_TIME_UNIT_FOREVER_REL);
663 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init)) 685 if ((NULL == (p = ph->pending_head)) || (GNUNET_YES != p->is_init))
664 { 686 {
665 p = GNUNET_malloc (sizeof (struct PendingMessage) + 687 p = GNUNET_malloc (sizeof (struct PendingMessage) +