From ef93f11e7c3e325e66d2644b989fc9b7b1cc2af6 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 19 Jan 2012 22:13:40 +0000 Subject: [PATCH] Fixed a memory leak on disconnect, double peer_rc decrease on tunnel destroy, adjusted backoff, completed doxygen --- src/mesh/mesh_api.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index c0b9a2a85..02811a502 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -267,7 +267,7 @@ struct GNUNET_MESH_Tunnel MESH_TunnelNumber tid; /** - * Owner of the tunnel + * Owner of the tunnel. 0 if the tunnel is the local client. */ GNUNET_PEER_Id owner; @@ -666,7 +666,7 @@ reconnect (struct GNUNET_MESH_Handle *h) { GNUNET_SCHEDULER_add_delayed (h->reconnect_time, &reconnect_cbk, h); h->reconnect_time = - GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS, + GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_SECONDS, GNUNET_TIME_relative_multiply (h->reconnect_time, 2)); LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Next retry in %sms\n", @@ -1264,6 +1264,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) { struct GNUNET_MESH_Tunnel *t; struct GNUNET_MESH_Tunnel *aux; + struct GNUNET_MESH_TransmitHandle *th; t = handle->tunnels_head; while (NULL != t) @@ -1272,6 +1273,20 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) destroy_tunnel (t); t = aux; } + while ( (th = handle->th_head) != NULL) + { + struct GNUNET_MessageHeader *msg; + + /* Make sure it is a connect packet (everything else should have been + * already canceled). + */ + GNUNET_break (UINT32_MAX == th->priority); + GNUNET_break (NULL == th->notify); + msg = (struct GNUNET_MessageHeader *) &th[1]; + GNUNET_break (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT == ntohs(msg->type)); + GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th); + GNUNET_free (th); + } if (NULL != handle->th) { GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); @@ -1331,9 +1346,6 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel) LOG (GNUNET_ERROR_TYPE_DEBUG, "mesh: Destroying tunnel\n"); h = tunnel->mesh; - if (0 != tunnel->owner) - GNUNET_PEER_change_rc (tunnel->owner, -1); - msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); msg.tunnel_id = htonl (tunnel->tid); -- 2.25.1