From 595afe519791894c77c77a949fba7732f4d94872 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Jan 2009 18:51:27 +0000 Subject: Whoops! You can't fix a problem in server and forget about ItoServer! That's just aweful! Well, he's not forgotten now. --- src/itoserver.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/itoserver.cpp b/src/itoserver.cpp index fc1f40b..c7328b4 100644 --- a/src/itoserver.cpp +++ b/src/itoserver.cpp @@ -148,9 +148,15 @@ void *Bu::ItoServer::ItoClient::run() struct timeval xTimeout = { nTimeoutSec, nTimeoutUSec }; fd_set fdRead = fdActive; + fd_set fdWrite; fd_set fdException = fdActive; - if( TEMP_FAILURE_RETRY( select( FD_SETSIZE, &fdRead, NULL, &fdException, &xTimeout ) ) < 0 ) + FD_ZERO( &fdWrite ); + if( pClient->hasOutput() ) + FD_SET( iSocket, &fdWrite ); + + if( TEMP_FAILURE_RETRY( select( FD_SETSIZE, + &fdRead, &fdWrite, &fdException, &xTimeout ) ) < 0 ) { throw ExceptionBase("Error attempting to scan open connections."); } @@ -182,12 +188,12 @@ void *Bu::ItoServer::ItoClient::run() } } - // Now we just try to write all the pending data on the socket. - // this could be done better eventually, if we care about the socket - // wanting to accept writes (using a select). - imProto.lock(); - pClient->processOutput(); - imProto.unlock(); + if( FD_ISSET( iSocket, &fdWrite ) ) + { + imProto.lock(); + pClient->processOutput(); + imProto.unlock(); + } } return NULL; -- cgit v1.2.3