X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FClientSocket.c;h=ad634dc4408388a28fa301de24d5c7bb17e8c2ab;hb=a0f5e337ee57df78939e9ddaccf9a18bcf811435;hp=c49577724393e3de6b1443841072ff8e1ed46105;hpb=c32e8254ec4ed0d77757e32f8aa5aabcdb494057;p=NeonServV5.git diff --git a/src/ClientSocket.c b/src/ClientSocket.c index c495777..ad634dc 100644 --- a/src/ClientSocket.c +++ b/src/ClientSocket.c @@ -35,7 +35,7 @@ static pthread_mutex_t synchronized; static pthread_mutex_t synchronized_recv; struct ParseOrder { - unsigned long tid; + unsigned int tid; struct ParseOrder *next; }; struct ParseOrder *parse_order = NULL; @@ -230,7 +230,7 @@ static int _connect_socket(struct ClientSocket *client) { return 1; } #else -static int connect_socket(struct ClientSocket *client) { +static int _connect_socket(struct ClientSocket *client) { if((client->flags & SOCKET_FLAG_CONNECTED)) return 1; struct hostent *host; struct sockaddr_in addr; @@ -376,7 +376,7 @@ int write_socket(struct ClientSocket *client, char* msg, int len) { } #if HAVE_THREADS -static void clientsocket_start_of_recv(unsigned long tid) { +static void clientsocket_start_of_recv(unsigned int tid) { SYNCHRONIZE(whohandler_sync); struct ParseOrder *entry, *last; for(last = parse_order; last; last = last->next) { @@ -393,7 +393,7 @@ static void clientsocket_start_of_recv(unsigned long tid) { DESYNCHRONIZE(whohandler_sync); } -static void clientsocket_end_of_recv(unsigned long tid) { +static void clientsocket_end_of_recv(unsigned int tid) { SYNCHRONIZE(whohandler_sync); struct ParseOrder *entry, *last = NULL; for(entry = parse_order; entry; entry = entry->next) { @@ -410,7 +410,7 @@ static void clientsocket_end_of_recv(unsigned long tid) { DESYNCHRONIZE(whohandler_sync); } -int clientsocket_parseorder_top(unsigned long tid) { +int clientsocket_parseorder_top(unsigned int tid) { if(parse_order && parse_order->tid == tid) return 1; else @@ -418,8 +418,8 @@ int clientsocket_parseorder_top(unsigned long 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 +439,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; @@ -494,7 +494,7 @@ void socket_loop(int timeout_seconds) { sock->bufferpos -= used; } is_synchronized = 0; - unsigned long tid = syscall(SYS_gettid); + unsigned int tid = (unsigned int) pthread_self_tid(); clientsocket_start_of_recv(tid); DESYNCHRONIZE(synchronized_recv); parse_lines(sock, linesbuf, used); @@ -530,6 +530,7 @@ void socket_loop(int timeout_seconds) { if(is_synchronized) { DESYNCHRONIZE(synchronized_recv); } + return (ret + 1); } void