aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2023-07-31 16:25:45 -0700
committerMike Buland <eichlan@xagasoft.com>2023-07-31 16:25:45 -0700
commitdcf2e2182934291e7312993c78d3d3c5f72597d5 (patch)
treee837286747714adc49b65932bd16c366e31cb7f8 /src/stable
parentfc83cb3fa5b15e9fb20a9180a3880297cf398de7 (diff)
downloadlibbu++-dcf2e2182934291e7312993c78d3d3c5f72597d5.tar.gz
libbu++-dcf2e2182934291e7312993c78d3d3c5f72597d5.tar.bz2
libbu++-dcf2e2182934291e7312993c78d3d3c5f72597d5.tar.xz
libbu++-dcf2e2182934291e7312993c78d3d3c5f72597d5.zip
Seems to work.
We have a last ditch effort. It turns out that the SocketTcp class automatically closes sockets when it realizes they're at the end, it doesn't wait for us to call close. That could be a problem, we may need something in between, but at least we can detect it and clean it up.
Diffstat (limited to '')
-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;