aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/server.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/server.cpp b/src/server.cpp
index eb85997..804bbcc 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -59,10 +59,18 @@ void Bu::Server::scan()
59 struct timeval xTimeout = { nTimeoutSec, nTimeoutUSec }; 59 struct timeval xTimeout = { nTimeoutSec, nTimeoutUSec };
60 60
61 fd_set fdRead = fdActive; 61 fd_set fdRead = fdActive;
62 fd_set fdWrite = fdActive; 62 fd_set fdWrite /* = fdActive*/;
63 fd_set fdException = fdActive; 63 fd_set fdException = fdActive;
64 64
65 if( TEMP_FAILURE_RETRY( select( FD_SETSIZE, &fdRead, NULL, &fdException, &xTimeout ) ) < 0 ) 65 FD_ZERO( &fdWrite );
66 for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ )
67 {
68 if( (*i)->hasOutput() )
69 FD_SET( i.getKey(), &fdWrite );
70 }
71
72 if( TEMP_FAILURE_RETRY( select( FD_SETSIZE,
73 &fdRead, &fdWrite, &fdException, &xTimeout ) ) < 0 )
66 { 74 {
67 throw ExceptionBase("Error attempting to scan open connections."); 75 throw ExceptionBase("Error attempting to scan open connections.");
68 } 76 }
@@ -88,6 +96,11 @@ void Bu::Server::scan()
88 } 96 }
89 } 97 }
90 } 98 }
99 if( FD_ISSET( j, &fdWrite ) )
100 {
101 Client *pClient = hClients.get( j );
102 pClient->processOutput();
103 }
91 } 104 }
92 105
93 Bu::List<int> lDelete; 106 Bu::List<int> lDelete;
@@ -96,8 +109,7 @@ void Bu::Server::scan()
96 // wanting to accept writes (using a select). 109 // wanting to accept writes (using a select).
97 for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ ) 110 for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ )
98 { 111 {
99 (*i)->processOutput(); 112 if( (*i)->wantsDisconnect() && !(*i)->hasOutput() )
100 if( (*i)->wantsDisconnect() )
101 { 113 {
102 lDelete.append( i.getKey() ); 114 lDelete.append( i.getKey() );
103 } 115 }