diff options
Diffstat (limited to 'src/itoserver.cpp')
-rw-r--r-- | src/itoserver.cpp | 20 |
1 files 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() | |||
148 | struct timeval xTimeout = { nTimeoutSec, nTimeoutUSec }; | 148 | struct timeval xTimeout = { nTimeoutSec, nTimeoutUSec }; |
149 | 149 | ||
150 | fd_set fdRead = fdActive; | 150 | fd_set fdRead = fdActive; |
151 | fd_set fdWrite; | ||
151 | fd_set fdException = fdActive; | 152 | fd_set fdException = fdActive; |
152 | 153 | ||
153 | if( TEMP_FAILURE_RETRY( select( FD_SETSIZE, &fdRead, NULL, &fdException, &xTimeout ) ) < 0 ) | 154 | FD_ZERO( &fdWrite ); |
155 | if( pClient->hasOutput() ) | ||
156 | FD_SET( iSocket, &fdWrite ); | ||
157 | |||
158 | if( TEMP_FAILURE_RETRY( select( FD_SETSIZE, | ||
159 | &fdRead, &fdWrite, &fdException, &xTimeout ) ) < 0 ) | ||
154 | { | 160 | { |
155 | throw ExceptionBase("Error attempting to scan open connections."); | 161 | throw ExceptionBase("Error attempting to scan open connections."); |
156 | } | 162 | } |
@@ -182,12 +188,12 @@ void *Bu::ItoServer::ItoClient::run() | |||
182 | } | 188 | } |
183 | } | 189 | } |
184 | 190 | ||
185 | // Now we just try to write all the pending data on the socket. | 191 | if( FD_ISSET( iSocket, &fdWrite ) ) |
186 | // this could be done better eventually, if we care about the socket | 192 | { |
187 | // wanting to accept writes (using a select). | 193 | imProto.lock(); |
188 | imProto.lock(); | 194 | pClient->processOutput(); |
189 | pClient->processOutput(); | 195 | imProto.unlock(); |
190 | imProto.unlock(); | 196 | } |
191 | } | 197 | } |
192 | 198 | ||
193 | return NULL; | 199 | return NULL; |