From d1cd3c81455ecb32149cbaa424b7870075b2b2fc Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 10 Jul 2011 22:46:43 +0200 Subject: [PATCH] Close meta connection socket after cleaning up event structures. 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 | 3 +++ src/net.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/connection.c b/src/connection.c index 956607c..713a40c 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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); } diff --git a/src/net.c b/src/net.c index 7ce4f31..8df87d6 100644 --- 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); -- 2.25.1