fixed unwanted shutdowns due "no more bots running"
authorpk910 <philipp@zoelle1.de>
Sat, 18 Feb 2012 01:46:05 +0000 (02:46 +0100)
committerpk910 <philipp@zoelle1.de>
Sat, 18 Feb 2012 01:46:05 +0000 (02:46 +0100)
src/ClientSocket.c

index 6cf36e2d187a90e77186452d7fccc1f3c11cc3fa..c6ac27a7dd2b845a410561d6b52d7111eadde4c1 100644 (file)
@@ -106,6 +106,7 @@ int connect_socket(struct ClientSocket *client) {
 #ifndef WIN32
 static int _connect_socket(struct ClientSocket *client) {
     if((client->flags & SOCKET_FLAG_CONNECTED)) return 1;
+    client->connection_time = time(0);
     int sock;
     
     struct addrinfo hints, *res;
@@ -207,7 +208,6 @@ static int _connect_socket(struct ClientSocket *client) {
     
     client->sock = sock;
     client->flags |= SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT;
-    client->connection_time = time(0);
     
     if(client->flags & SOCKET_FLAG_SSL) {
         ssl_connect(client);
@@ -233,6 +233,7 @@ static int _connect_socket(struct ClientSocket *client) {
 #else
 static int _connect_socket(struct ClientSocket *client) {
     if((client->flags & SOCKET_FLAG_CONNECTED)) return 1;
+    client->connection_time = time(0);
     struct hostent *host;
     struct sockaddr_in addr;
     int sock;
@@ -262,7 +263,6 @@ static int _connect_socket(struct ClientSocket *client) {
 
     client->sock = sock;
     client->flags |= SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT;
-    client->connection_time = time(0);
 
 
     if(client->flags & SOCKET_FLAG_SSL) {
@@ -445,10 +445,6 @@ int socket_loop(int timeout_seconds) {
     timeout.tv_sec = timeout_seconds;
     timeout.tv_usec = 0;
     ret = select(ret + 1, &fds, NULL, NULL, &timeout);
-    if(ret == 0) {
-        DESYNCHRONIZE(synchronized_recv);
-        return 1;
-    }
     for (sock = sockets->data; sock; sock = next) {
         next = sock->next;
         if((sock->flags & (SOCKET_FLAG_CONNECTED | SOCKET_FLAG_QUITTED)) == SOCKET_FLAG_CONNECTED && FD_ISSET(sock->sock, &fds)) {
@@ -538,7 +534,7 @@ int socket_loop(int timeout_seconds) {
     if(is_synchronized) {
         DESYNCHRONIZE(synchronized_recv);
     }
-    return (ret + 1);
+    return 1;
 }
 
 void