X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FClientSocket.c;h=eb11d88fc131558ff1bb698f883c37bd91144188;hb=19160d1e7f3bf41a6f7edbc5ec539d4588e1c69a;hp=3be703765123bcbe931f7dd5c03ffa2f174da235;hpb=83c4b223cac21b7177bd1e276c326eb020bfb887;p=NeonServV5.git diff --git a/src/ClientSocket.c b/src/ClientSocket.c index 3be7037..eb11d88 100644 --- a/src/ClientSocket.c +++ b/src/ClientSocket.c @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +#include "main.h" #include "ClientSocket.h" #include "IRCParser.h" #include "UserNode.h" @@ -222,6 +222,8 @@ static IOHANDLER_CALLBACK(socket_callback) { #ifdef HAVE_THREADS unsigned int tid; #endif + if(process_state.running == 0) + return; //just ignore the event (shutdown sequence) switch(event->type) { case IOEVENT_CONNECTED: client->flags |= SOCKET_FLAG_CONNECTED; @@ -285,13 +287,19 @@ struct ClientSocket* getBots(int flags, struct ClientSocket* last_bot) { return NULL; } -void free_sockets() { +void free_sockets(int close_only) { if(!sockets) return; struct ClientSocket *client, *next; for (client = sockets->data; client; client = next) { next = client->next; - destroy_socket(client); + if(close_only) { + if((client->flags & SOCKET_FLAG_CONNECTED)) + iohandler_printf(client->iofd, "QUIT :[NeonServ %s.%d] shutdown requested.\n", NEONSERV_VERSION, patchlevel); + } else + destroy_socket(client); + } + if(!close_only) { + free(sockets); + sockets = NULL; } - free(sockets); - sockets = NULL; }