From 5cbded5473f8d3fef74f6e13edb7fa606d7e371b Mon Sep 17 00:00:00 2001 From: Valeska Date: Wed, 12 Feb 2014 19:00:33 -0800 Subject: [PATCH] Copied Michele Bini's threading fixes. https://github.com/Netsukuku/netsukuku/compare/debian-lenny-compilation-fixes Some of these are specifically for debian lenny 2008! Do NOT use them all, They will break your installation of netsukuku. I will try to set it up properly. --- src/daemon.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/daemon.c b/src/daemon.c index b852389..015b8d6 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -366,15 +366,18 @@ void *tcp_daemon(void *door) * While we are accepting the connections we keep the socket non * blocking. */ - if(set_nonblock_sk(dev_sk[i])) - return NULL; - - /* Shhh, it's listening... */ - if(listen(dev_sk[i], 5) == -1) { - inet_close(&dev_sk[i]); - return NULL; + if(set_nonblock_sk(dev_sk[i])) { + pthread_mutex_unlock(&tcp_daemon_lock); + return NULL; } - } + + /* Shhh, it's listening... */ + if(listen(dev_sk[i], 5) == -1) { + inet_close(&dev_sk[i]); + pthread_mutex_unlock(&tcp_daemon_lock); + return NULL; + } + } debug(DBG_NORMAL, "Tcp daemon on port %d up & running", tcp_port); pthread_mutex_unlock(&tcp_daemon_lock);