diff options
author | Mike Buland <eichlan@xagasoft.com> | 2023-07-31 16:25:45 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2023-07-31 16:25:45 -0700 |
commit | dcf2e2182934291e7312993c78d3d3c5f72597d5 (patch) | |
tree | e837286747714adc49b65932bd16c366e31cb7f8 /src/stable/server.cpp | |
parent | fc83cb3fa5b15e9fb20a9180a3880297cf398de7 (diff) | |
download | libbu++-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.cpp | 35 |
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 | ||
561 | void 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 | //// |