aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable')
-rw-r--r--src/stable/server.cpp35
-rw-r--r--src/stable/server.h1
2 files changed, 22 insertions, 14 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////
diff --git a/src/stable/server.h b/src/stable/server.h
index a839968..9fb8282 100644
--- a/src/stable/server.h
+++ b/src/stable/server.h
@@ -161,7 +161,6 @@ namespace Bu
161 private: 161 private:
162 void handleRead( Client *pClient, Socket *pSocket ); 162 void handleRead( Client *pClient, Socket *pSocket );
163 void handleWrite( Client *pClient, Socket *pSocket ); 163 void handleWrite( Client *pClient, Socket *pSocket );
164 void close( Socket *pSocket );
165 164
166 private: 165 private:
167 Server &rSrv; 166 Server &rSrv;