]> git.meshlink.io Git - meshlink/commitdiff
Struct outgoing needs to remember to which mesh it belongs.
authorGuus Sliepen <guus@meshlink.io>
Fri, 25 Jul 2014 22:24:02 +0000 (00:24 +0200)
committerGuus Sliepen <guus@meshlink.io>
Fri, 25 Jul 2014 22:24:02 +0000 (00:24 +0200)
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
src/net_socket.c

index f76e2df43b99a9ade8ebd1be189b88ccdcfa3ec9..6014a3d6207881d15b4fbc8bbfe8aa8f43d48f2e 100644 (file)
--- 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;
index 7b6c493baeb30cc84935479a95d5e62e87a644f3..85f51648dc81955f87b8c946f40e3bd6f059f2bc 100644 (file)
@@ -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);