From 8a97c8cbfa35cd052e18c6903a11de8a0e2362f3 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 26 Jul 2014 00:24:02 +0200 Subject: [PATCH] Struct outgoing needs to remember to which mesh it belongs. The reason is that since free_outgoing() is called by the list algorithms, it can take only one parameter (a pointer to a struct outgoing). --- src/net.h | 1 + src/net_socket.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index f76e2df4..6014a3d6 100644 --- a/src/net.h +++ b/src/net.h @@ -66,6 +66,7 @@ typedef struct outgoing_t { struct addrinfo *ai; struct addrinfo *aip; timeout_t ev; + struct meshlink_handle *mesh; } outgoing_t; extern int maxoutbufsize; diff --git a/src/net_socket.c b/src/net_socket.c index 7b6c493b..85f51648 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -632,7 +632,9 @@ void handle_new_meta_connection(event_loop_t *loop, void *data, int flags) { send_id(mesh, c); } -static void free_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) { +static void free_outgoing(outgoing_t *outgoing) { + meshlink_handle_t *mesh = outgoing->mesh; + timeout_del(&mesh->loop, &outgoing->ev); if(outgoing->ai) @@ -684,6 +686,7 @@ void try_outgoing_connections(meshlink_handle_t *mesh) { if(!found) { outgoing_t *outgoing = xzalloc(sizeof *outgoing); + outgoing->mesh = mesh; outgoing->name = name; list_insert_tail(mesh->outgoings, outgoing); setup_outgoing_connection(mesh, outgoing); -- 2.39.5