From ec585b15eb1e59cb7bacf996321f2a369aea11bf Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Tue, 23 Jul 2013 12:51:47 +0000 Subject: [PATCH] - don't leak memory on repeated PATH_CREATE --- src/mesh/gnunet-service-mesh.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index a3847792f..504eeb1e3 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -4044,23 +4044,27 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " It's for us!\n"); peer_info_add_path_to_origin (orig_peer_info, path, GNUNET_YES); + /* This can be a retransmission due to a lost PATH ACK. + * Check if we already have a destination client for the tunnel. */ + if (t->client != c) + { + /* Assign local tid */ + while (NULL != tunnel_get_incoming (next_local_tid)) + next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; + t->local_tid_dest = next_local_tid++; + next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; - /* Assign local tid */ - while (NULL != tunnel_get_incoming (next_local_tid)) - next_local_tid = (next_local_tid + 1) | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; - t->local_tid_dest = next_local_tid++; - next_local_tid = next_local_tid | GNUNET_MESH_LOCAL_TUNNEL_ID_SERV; + if (GNUNET_YES == t->reliable) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); + t->bck_rel = GNUNET_malloc (sizeof (struct MeshTunnelReliability)); + t->bck_rel->t = t; + t->bck_rel->expected_delay = MESH_RETRANSMIT_TIME; + } - if (GNUNET_YES == t->reliable) - { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); - t->bck_rel = GNUNET_malloc (sizeof (struct MeshTunnelReliability)); - t->bck_rel->t = t; - t->bck_rel->expected_delay = MESH_RETRANSMIT_TIME; + tunnel_add_client (t, c); + send_local_tunnel_create (t); } - - tunnel_add_client (t, c); - send_local_tunnel_create (t); send_path_ack (t); /* Eliminate tunnel when origin dies */ tunnel_reset_timeout (t, GNUNET_YES); -- 2.25.1