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 956607c..713a40c 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 7ce4f31..8df87d6 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);