]> git.meshlink.io Git - meshlink/commitdiff
Close meta connection socket after cleaning up event structures.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 10 Jul 2011 20:46:43 +0000 (22:46 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 10 Jul 2011 20:46:43 +0000 (22:46 +0200)
Epoll doesn't like it when an already closed filedescriptor is being
removed, so we defer closing the socket until after all else is cleaned
up.

src/connection.c
src/net.c

index 956607caaeb0c49ef72db81ad287f8483f787536..713a40cbfc12fb76147345291264c1e64f78dd4c 100644 (file)
@@ -87,6 +87,9 @@ void free_connection(connection_t *c) {
        if(event_initialized(&c->outevent))
                event_del(&c->outevent);
 
+       if(c->socket > 0)
+               closesocket(c->socket);
+
        free(c);
 }
 
index 7ce4f318bd732486770de4ee8adc68762da25104..8df87d6ef71e7e39b4aa2aa41b118a1a3fea5388 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -116,9 +116,6 @@ void terminate_connection(connection_t *c, bool report) {
        if(c->node)
                c->node->connection = NULL;
 
-       if(c->socket)
-               closesocket(c->socket);
-
        if(c->edge) {
                if(report && !tunnelserver)
                        send_del_edge(broadcast, c->edge);