From b862d290ab28a49c03a7b2a1adf85af17e8813b8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 2 Jul 2011 21:00:11 +0000 Subject: [PATCH] fixing 1714 --- src/transport/gnunet-service-transport.c | 57 +++++++++++++----------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 4cae96273..b9e3e79b8 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1854,6 +1854,22 @@ static void mark_address_connected (struct ForeignAddressList *fal); + +/** + * We should re-try transmitting to the given peer, + * hopefully we've learned something in the meantime. + */ +static void +retry_transmission_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct NeighbourList *n = cls; + + n->retry_task = GNUNET_SCHEDULER_NO_TASK; + try_transmission_to_peer (n); +} + + /** * Function called by the GNUNET_TRANSPORT_TransmitFunction * upon "completion" of a send request. This tells the API @@ -1925,33 +1941,24 @@ transmit_send_continuation (void *cls, if (! mq->internal_msg) mq->specific_address->in_transmit = GNUNET_NO; } - n = find_neighbour(&mq->neighbour_id); + n = find_neighbour (&mq->neighbour_id); if (mq->client != NULL) transmit_send_ok (mq->client, n, target, result); if (n != NULL) - { - GNUNET_CONTAINER_DLL_remove (n->cont_head, - n->cont_tail, - mq); - } + { + GNUNET_CONTAINER_DLL_remove (n->cont_head, + n->cont_tail, + mq); + } GNUNET_free (mq); - if (n != NULL) - try_transmission_to_peer (n); -} - - -/** - * We should re-try transmitting to the given peer, - * hopefully we've learned something in the meantime. - */ -static void -retry_transmission_task (void *cls, - const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct NeighbourList *n = cls; - - n->retry_task = GNUNET_SCHEDULER_NO_TASK; - try_transmission_to_peer (n); + if (n != NULL) + { + if (result == GNUNET_OK) + try_transmission_to_peer (n); + else if (GNUNET_SCHEDULER_NO_TASK == n->retry_task) + n->retry_task = GNUNET_SCHEDULER_add_now (&retry_transmission_task, + n); + } } @@ -2030,8 +2037,8 @@ try_transmission_to_peer (struct NeighbourList *n) if (n->retry_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (n->retry_task); n->retry_task = GNUNET_SCHEDULER_add_delayed (timeout, - &retry_transmission_task, - n); + &retry_transmission_task, + n); #if DEBUG_TRANSPORT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No validated destination address available to transmit message of size %u to peer `%4s', will wait %llums to find an address.\n", -- 2.25.1