*** VERSION 5.6.0 ***
[NeonServV5.git] / src / ClientSocket.c
index 13f8b6b6d55f82b9debe72288f0422f35694f197..3c05457da8d90d733a53b891e14fbc6c7d10f75e 100644 (file)
@@ -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
@@ -61,6 +61,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;
@@ -215,7 +217,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 +247,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);