fixed debug/log output of sent data (don't add a second \n)
[NeonServV5.git] / src / ClientSocket.c
index 6d2c34e5d20efe744237d1d6b3fab270a15c7607..eab5204dfc720fd08395bba0457750fe2b375062 100644 (file)
@@ -354,7 +354,11 @@ static void destroy_socket(struct ClientSocket *client, int free_socket) {
 
 int write_socket_force(struct ClientSocket *client, char* msg, int len) {
     SYNCHRONIZE(synchronized);
-    printf("[send %d] %s", len, msg);
+    #ifdef HAVE_THREADS
+    putlog(LOGLEVEL_RAW, "[%d send %d] %s", getCurrentThreadID(), len, msg);
+    #else
+    putlog(LOGLEVEL_RAW, "[send %d] %s", len, msg);
+    #endif
     if(!(client->flags & SOCKET_FLAG_HAVE_SSL) || ssl_write(client, msg, len) == -2) {
         #ifdef WIN32
         send(client->sock, msg, len, 0);
@@ -418,8 +422,8 @@ int clientsocket_parseorder_top(unsigned int tid) {
 }
 #endif
 
-void socket_loop(int timeout_seconds) {
-    if(sockets == NULL) return;
+int socket_loop(int timeout_seconds) {
+    if(sockets == NULL) return 0;
     int is_synchronized = 1;
     SYNCHRONIZE(synchronized_recv);
     fd_set fds;
@@ -439,7 +443,7 @@ void socket_loop(int timeout_seconds) {
     ret = select(ret + 1, &fds, NULL, NULL, &timeout);
     if(ret == 0) {
         DESYNCHRONIZE(synchronized_recv);
-        return;
+        return 1;
     }
     for (sock = sockets->data; sock; sock = next) {
         next = sock->next;
@@ -530,6 +534,7 @@ void socket_loop(int timeout_seconds) {
     if(is_synchronized) {
         DESYNCHRONIZE(synchronized_recv);
     }
+    return (ret + 1);
 }
 
 void