From: Guus Sliepen Date: Sat, 15 Jan 2011 21:21:31 +0000 (+0100) Subject: Call connect() from the metadata handler thread. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2d4203fefa52a41f7987b1ace254da77df6e2dbf;p=oweals%2Ftinc.git Call connect() from the metadata handler thread. --- diff --git a/src/net.c b/src/net.c index e52363e..d80a712 100644 --- a/src/net.c +++ b/src/net.c @@ -216,13 +216,12 @@ void handle_meta_connection_data(void *data) { int result; socklen_t len = sizeof result; - if(c->status.connecting) { - c->status.connecting = false; - - getsockopt(c->socket, SOL_SOCKET, SO_ERROR, &result, &len); + while(c->status.connecting) { + result = connect(c->socket, &c->address.sa, SALEN(c->address.sa)); if(!result) { mutex_lock(&mutex); + c->status.connecting = false; finish_connecting(c); mutex_unlock(&mutex); } else { @@ -230,10 +229,10 @@ void handle_meta_connection_data(void *data) { "Error while connecting to %s (%s): %s", c->name, c->hostname, sockstrerror(result)); closesocket(c->socket); + c->status.connecting = false; mutex_lock(&mutex); do_outgoing_connection(c); mutex_unlock(&mutex); - return; } } diff --git a/src/net_socket.c b/src/net_socket.c index 3c79cee..d12810f 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -392,25 +392,7 @@ begin: configure_tcp(c); - /* Connect */ - - result = connect(c->socket, &c->address.sa, SALEN(c->address.sa)); - - if(result == -1) { - if(sockinprogress(sockerrno)) { - c->status.connecting = true; - return; - } - - closesocket(c->socket); - - ifdebug(CONNECTIONS) logger(LOG_ERR, "%s: %s", c->hostname, sockstrerror(sockerrno)); - - goto begin; - } - - finish_connecting(c); - + c->status.connecting = true; return; }