diff options
author | Mike Buland <eichlan@xagasoft.com> | 2009-01-09 07:55:02 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2009-01-09 07:55:02 +0000 |
commit | 861e5bd7d3df941685f048d7039029b83ec87cb9 (patch) | |
tree | f82f1a58134f72036a67988237e33ae85bf36e83 /src/server.cpp | |
parent | aba7c45c2c69d402d1b6fc427cde5bfa4661a0e1 (diff) | |
download | libbu++-861e5bd7d3df941685f048d7039029b83ec87cb9.tar.gz libbu++-861e5bd7d3df941685f048d7039029b83ec87cb9.tar.bz2 libbu++-861e5bd7d3df941685f048d7039029b83ec87cb9.tar.xz libbu++-861e5bd7d3df941685f048d7039029b83ec87cb9.zip |
Hey, that's better. The server now idles the same, but sends data uber-fast!
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 20 |
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 | } |