Merge branch 'master' into IOMultiplexer
[NeonServV5.git] / src / signal.c
index 37f66f38671d98cf9f9a911963e7bb96ad26e905..175f61150db18ba33863ba979eef4d3953be9eef 100644 (file)
@@ -18,6 +18,7 @@
 #include "bots.h"
 #include "ChanNode.h"
 #include "ClientSocket.h"
+#include "IOHandler.h"
 #include "ConfigParser.h"
 
 static void sigcrash();
@@ -85,8 +86,9 @@ static void sigcrash(int signum) {
     struct ClientSocket *bot;
     for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
         if((bot->flags & SOCKET_FLAG_CONNECTED)) {
-            close(bot->sock);
-            bot->flags &= SOCKET_FLAG_CONNECTED;
+            iohandler_close(bot->iofd);
+            bot->flags &= ~(SOCKET_FLAG_CONNECTED | SOCKET_FLAG_READY);
+            bot->iofd = NULL;
         }
     }
     putlog(LOGLEVEL_INFO, "hard shutdown...\n");