From: Guus Sliepen Date: Fri, 25 Jul 2014 22:24:02 +0000 (+0200) Subject: Struct outgoing needs to remember to which mesh it belongs. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=8a97c8cbfa35cd052e18c6903a11de8a0e2362f3;p=meshlink 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). --- 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);