Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / ClientSocket.c
index 6b8b4fb815d5f4728414e9cf30f14998ad1c73d5..2897d9d8ca722f6b5dceada83a71e792baf5082d 100644 (file)
@@ -1,5 +1,5 @@
 /* ClientSocket.c - NeonServ v5.3
- * Copyright (C) 2011  Philipp Kreil (pk910)
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -269,8 +269,6 @@ int close_socket(struct ClientSocket *client) {
         char quitbuf[MAXLEN];
         int quitlen = sprintf(quitbuf, "QUIT :[NeonServ %s.%d] disconnect requested.\n", NEONSERV_VERSION, patchlevel);
         write_socket_force(client, quitbuf, quitlen);
-        close(client->sock);
-        bot_disconnect(client);
     }
     client->flags &= ~(SOCKET_FLAG_READY | SOCKET_FLAG_RECONNECT);
     client->flags |= SOCKET_FLAG_QUITTED | SOCKET_FLAG_DEAD;
@@ -369,7 +367,7 @@ void socket_loop(int timeout_seconds) {
     if(ret == 0) return;
     for (sock = sockets->data; sock; sock = next) {
         next = sock->next;
-        if((sock->flags & SOCKET_FLAG_CONNECTED) && FD_ISSET(sock->sock, &fds)) {
+        if((sock->flags & (SOCKET_FLAG_CONNECTED | SOCKET_FLAG_QUITTED)) == SOCKET_FLAG_CONNECTED && FD_ISSET(sock->sock, &fds)) {
             if(sock->bufferpos != 0) {
                 if(!(sock->flags & SOCKET_FLAG_HAVE_SSL) || (bytes = ssl_read(sock, buffer, sizeof(buffer))) == -2) {
                     #ifdef WIN32
@@ -412,7 +410,7 @@ void socket_loop(int timeout_seconds) {
                     sock->bufferpos -= used;
                 }
             }
-        } else if(!(sock->flags & SOCKET_FLAG_CONNECTED) && (sock->flags & SOCKET_FLAG_RECONNECT)) {
+        } else if((sock->flags & (SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT)) == SOCKET_FLAG_RECONNECT) {
             if(time(0) - sock->connection_time >= SOCKET_RECONNECT_TIME) {
                 connect_socket(sock);
             }