aboutsummaryrefslogtreecommitdiff
path: root/src/stable/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/server.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/stable/server.cpp b/src/stable/server.cpp
index 160b3eb..3aa8a34 100644
--- a/src/stable/server.cpp
+++ b/src/stable/server.cpp
@@ -204,13 +204,29 @@ void Bu::Server::addClient( const Bu::ServerSocket *pSrv, Bu::Socket *pSocket )
204 ); 204 );
205 { 205 {
206 Bu::MutexLocker l( mClients ); 206 Bu::MutexLocker l( mClients );
207 if( hClients.has( iFdCli ) ) 207 if( hClients.has( iFdCli ) || hSockets.has( iFdCli ) )
208 { 208 {
209 Bu::println("!!!!!!!!! hClients has %1 already.").arg( iFdCli ); 209 // Oops, it got closed and we haven't managed to get to it yet.
210 } 210 // We're not going to be able to write anyhting, we may as well
211 if( hSockets.has( iFdCli ) ) 211 // just clean up.
212 { 212 //
213 Bu::println("!!!!!!!!! hSockets has %1 already.").arg( iFdCli ); 213 // This can happen in a variety of situations, but mostly when
214 // we get a disconnect followed immediately be a reconnect.
215 struct epoll_event ev;
216 epoll_ctl( pCore->fdRead, EPOLL_CTL_DEL, iFdCli, &ev );
217 epoll_ctl( pCore->fdWrite, EPOLL_CTL_DEL, iFdCli, &ev );
218 Client *pOldClient = hClients.get( iFdCli );
219 Socket *pOldSocket = hSockets.get( iFdCli );
220
221 hClients.erase( iFdCli );
222 hSockets.erase( iFdCli );
223
224 onClosedConnection( pOldClient );
225 pOldClient->close();
226 pOldSocket->close();
227
228 delete pOldClient;
229 delete pOldSocket;
214 } 230 }
215 hClients.insert( iFdCli, pClient ); 231 hClients.insert( iFdCli, pClient );
216 hSockets.insert( iFdCli, pSocket ); 232 hSockets.insert( iFdCli, pSocket );
@@ -558,13 +574,6 @@ void Bu::Server::IoWorker::handleWrite( Client *pClient, Socket *pSocket )
558 } 574 }
559} 575}
560 576
561void Bu::Server::IoWorker::close( Bu::Socket *pSocket )
562{
563// Bu::Server::fd iFd;
564// pSocket->getFd( iFd );
565// rSrv.closeClient( iFd );
566}
567
568///////// 577/////////
569// ClientWorker 578// ClientWorker
570//// 579////