X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2FClientSocket.c;h=eaf43d46991b213ebc1021de875f21bfa74e53c1;hp=13f8b6b6d55f82b9debe72288f0422f35694f197;hb=8a1a716ef73af7b5288f7b5f8ab1b37be80f1247;hpb=9eb6179eb4d2c394c7913eda496c922cb8c5d1a8 diff --git a/src/ClientSocket.c b/src/ClientSocket.c index 13f8b6b..eaf43d4 100644 --- a/src/ClientSocket.c +++ b/src/ClientSocket.c @@ -1,4 +1,4 @@ -/* ClientSocket.c - NeonServ v5.5 +/* ClientSocket.c - NeonServ v5.6 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -24,6 +24,7 @@ #include "ConfigParser.h" #include "version.h" #include "IOHandler.h" +#include "IRCEvents.h" struct socket_list { struct ClientSocket *data; @@ -61,6 +62,8 @@ void init_sockets() { } struct ClientSocket* create_socket(char *host, int port, char *bindto, char *pass, char *nick, char *ident, char *realname) { + if(!sockets) + init_sockets(); struct ClientSocket *client = malloc(sizeof(*client)); if (!client) { return NULL; @@ -134,6 +137,7 @@ int destroy_socket(struct ClientSocket *client) { } else last_sock = sock; } + event_freeclient(client); free(client->host); if(client->bind) free(client->bind); @@ -215,7 +219,9 @@ int clientsocket_parseorder_top(unsigned int tid) { static IOHANDLER_CALLBACK(socket_callback) { struct ClientSocket *client = event->iofd->data; + #ifdef HAVE_THREADS unsigned int tid; + #endif switch(event->type) { case IOEVENT_CONNECTED: client->flags |= SOCKET_FLAG_CONNECTED; @@ -243,6 +249,7 @@ static IOHANDLER_CALLBACK(socket_callback) { tid = (unsigned int) pthread_self_tid(); clientsocket_start_of_recv(tid); #endif + client->traffic_in += strlen(event->data.recv_str); parse_line(client, event->data.recv_str); #ifdef HAVE_THREADS clientsocket_end_of_recv(tid);