From 82acee90436c8ab6fc736be4b9daf269af6352d2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 3 Sep 2011 09:28:25 +0000 Subject: [PATCH] LRN: A bit less dirty transport crash fix Basically, it now also frees mq before returning. The logic is kinda complex for such a small thing, but it's either that, or having two GNUNET_free (mq) statements. Although maybe you can postpone freeing mq until the end of the function (see v2 patch). [this is the v2 patch] --- src/transport/gnunet-service-transport.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 74ff1749c..07e9a0d89 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1613,22 +1613,21 @@ transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target, mq->specific_address->in_transmit = GNUNET_NO; } n = find_neighbour (&mq->neighbour_id); - if (n == NULL) + if (n != NULL) { + if (mq->client != NULL) + transmit_send_ok (mq->client, n, target, result); + GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); + 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); + } + else GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation", "Neighbour `%s' no longer exists\n", GNUNET_i2s (&mq->neighbour_id)); - return; - } - if (mq->client != NULL) - transmit_send_ok (mq->client, n, target, result); - GNUNET_assert (n != NULL); - GNUNET_CONTAINER_DLL_remove (n->cont_head, n->cont_tail, mq); GNUNET_free (mq); - 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); } -- 2.25.1