From ae117b6b4a7d98948b9fabbe961abbc45f00f6bd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 29 Jan 2017 13:09:48 +0100 Subject: [PATCH] provide stricter assurances about when we call ready_cb, avoiding supurious calls that merely reinforce what tunnel already knows about the connection state --- src/cadet/gnunet-service-cadet-new_connection.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 11044d9e6..b894c26f2 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c @@ -345,6 +345,8 @@ GCC_handle_connection_create_ack (struct CadetConnection *cc) GCC_2s (cc), cc->state, (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy"); + if (CADET_CONNECTION_READY == cc->state) + return; /* Duplicate ACK, ignore */ if (NULL != cc->task) { GNUNET_SCHEDULER_cancel (cc->task); @@ -522,8 +524,9 @@ GCC_handle_duplicate_create (struct CadetConnection *cc) (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy"); /* Tell tunnel that we are not ready for transmission anymore (until CREATE_ACK is done) */ - cc->ready_cb (cc->ready_cb_cls, - GNUNET_NO); + if (CADET_CONNECTION_READY == cc->state) + cc->ready_cb (cc->ready_cb_cls, + GNUNET_NO); /* Revert back to the state of having only received the 'CREATE', and immediately proceed to send the CREATE_ACK. */ cc->state = CADET_CONNECTION_CREATE_RECEIVED; @@ -566,7 +569,6 @@ manage_first_hop_mq (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Core MQ for %s went down\n", GCC_2s (cc)); - cc->mqm_ready = GNUNET_NO; cc->state = CADET_CONNECTION_NEW; cc->retry_delay = GNUNET_TIME_UNIT_ZERO; if (NULL != cc->task) @@ -574,8 +576,13 @@ manage_first_hop_mq (void *cls, GNUNET_SCHEDULER_cancel (cc->task); cc->task = NULL; } - cc->ready_cb (cc->ready_cb_cls, - GNUNET_NO); + if (GNUNET_YES == cc->mqm_ready) + { + cc->mqm_ready = GNUNET_NO; + if (CADET_CONNECTION_READY == cc->state) + cc->ready_cb (cc->ready_cb_cls, + GNUNET_NO); + } return; } -- 2.25.1