From: Matthias Wachs Date: Tue, 28 Jun 2011 12:33:06 +0000 (+0000) Subject: fixing memory leak mantis #1700 X-Git-Tag: initial-import-from-subversion-38251~18026 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=196247d4c8ca504115784600a9809d1129f33d22;p=oweals%2Fgnunet.git fixing memory leak mantis #1700 --- diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 51e84e1dd..b96ae6c22 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -488,6 +488,18 @@ struct NeighbourList */ struct MessageQueue *messages_tail; + /** + * Head of list of messages of messages we expected the continuation + * to be called to destroy the message + */ + struct MessageQueue *cont_head; + + /** + * Tail of list of messages of messages we expected the continuation + * to be called to destroy the message + */ + struct MessageQueue *cont_tail; + /** * Buffer for at most one payload message used when we receive * payload data before our PING-PONG has succeeded. We then @@ -1909,6 +1921,12 @@ transmit_send_continuation (void *cls, 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_free (mq); if (n != NULL) try_transmission_to_peer (n); @@ -2047,6 +2065,11 @@ try_transmission_to_peer (struct NeighbourList *n) gettext_noop ("# bytes pending with plugins"), mq->message_buf_size, GNUNET_NO); + + GNUNET_CONTAINER_DLL_insert (n->cont_head, + n->cont_tail, + mq); + ret = rl->plugin->api->send (rl->plugin->api->cls, &mq->neighbour_id, mq->message_buf, @@ -5116,6 +5139,19 @@ disconnect_neighbour (struct NeighbourList *n, int check) sizeof(struct GNUNET_PeerIdentity))); GNUNET_free (mq); } + + while (NULL != (mq = n->cont_head)) + { + + GNUNET_CONTAINER_DLL_remove (n->cont_head, + n->cont_tail, + mq); + GNUNET_assert (0 == memcmp(&mq->neighbour_id, + &n->id, + sizeof(struct GNUNET_PeerIdentity))); + GNUNET_free (mq); + } + if (n->timeout_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (n->timeout_task);