X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FClientSocket.c;h=cdf76f4fea8ef9113c4d309b553d8c473144f971;hb=78e040af3fcc36ab684611c0f98b4381ff420878;hp=d1f80ff8773358a09a9c557b216afbea9c8490c8;hpb=406c308308e4d131475a692cd425cb156e0776f1;p=NeonServV5.git diff --git a/src/ClientSocket.c b/src/ClientSocket.c index d1f80ff..cdf76f4 100644 --- a/src/ClientSocket.c +++ b/src/ClientSocket.c @@ -1,4 +1,4 @@ -/* ClientSocket.c - NeonServ v5.4 +/* ClientSocket.c - NeonServ v5.5 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -106,6 +106,7 @@ int connect_socket(struct ClientSocket *client) { #ifndef WIN32 static int _connect_socket(struct ClientSocket *client) { if((client->flags & SOCKET_FLAG_CONNECTED)) return 1; + client->connection_time = time(0); int sock; struct addrinfo hints, *res; @@ -207,7 +208,6 @@ static int _connect_socket(struct ClientSocket *client) { client->sock = sock; client->flags |= SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT; - client->connection_time = time(0); if(client->flags & SOCKET_FLAG_SSL) { ssl_connect(client); @@ -233,6 +233,7 @@ static int _connect_socket(struct ClientSocket *client) { #else static int _connect_socket(struct ClientSocket *client) { if((client->flags & SOCKET_FLAG_CONNECTED)) return 1; + client->connection_time = time(0); struct hostent *host; struct sockaddr_in addr; int sock; @@ -262,7 +263,6 @@ static int _connect_socket(struct ClientSocket *client) { client->sock = sock; client->flags |= SOCKET_FLAG_CONNECTED | SOCKET_FLAG_RECONNECT; - client->connection_time = time(0); if(client->flags & SOCKET_FLAG_SSL) { @@ -362,16 +362,17 @@ int write_socket_force(struct ClientSocket *client, char* msg, int len) { #else putlog(LOGLEVEL_RAW, "[send %d] %s", len, msg); #endif + int ret = 1; if(!(client->flags & SOCKET_FLAG_HAVE_SSL) || ssl_write(client, msg, len) == -2) { #ifdef WIN32 - send(client->sock, msg, len, 0); + ret = send(client->sock, msg, len, 0); #else - write(client->sock, msg, len); + ret = write(client->sock, msg, len); #endif } client->traffic_out += len; DESYNCHRONIZE(synchronized); - return 1; + return ret; } int write_socket(struct ClientSocket *client, char* msg, int len) { @@ -444,10 +445,6 @@ int socket_loop(int timeout_seconds) { timeout.tv_sec = timeout_seconds; timeout.tv_usec = 0; ret = select(ret + 1, &fds, NULL, NULL, &timeout); - if(ret == 0) { - DESYNCHRONIZE(synchronized_recv); - return 1; - } for (sock = sockets->data; sock; sock = next) { next = sock->next; if((sock->flags & (SOCKET_FLAG_CONNECTED | SOCKET_FLAG_QUITTED)) == SOCKET_FLAG_CONNECTED && FD_ISSET(sock->sock, &fds)) { @@ -537,7 +534,7 @@ int socket_loop(int timeout_seconds) { if(is_synchronized) { DESYNCHRONIZE(synchronized_recv); } - return (ret + 1); + return 1; } void