From 9a7dde29dc1bc1f699508ad9c0335f4d7abf319f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 31 Jul 2023 11:16:58 -0700 Subject: It actually works. Now to make it fast fast. --- src/stable/clientbuf.cpp | 4 ++-- src/stable/server.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/stable/clientbuf.cpp b/src/stable/clientbuf.cpp index 4e59120..c6b310f 100644 --- a/src/stable/clientbuf.cpp +++ b/src/stable/clientbuf.cpp @@ -200,9 +200,9 @@ Bu::size Bu::ClientBuf::ClientAccess::peek( void *pData, int iBytes, // Do we have enough data in the peek buffer to handle this? if( qbPeek.getSize() < iBytes+iOffset ) { - Bu::println("ClientAccess::peek: Insufficient buffered data (%1)").arg( qbPeek.getSize() ); + Bu::println("ClientAccess::peek: Insufficient buffered (have %1b, need %2b)").arg( qbPeek.getSize() ).arg( iBytes+iOffset ); // Nope, make an attempt to fill it in. - int nDiff = iBytes-qbPeek.getSize(); + int nDiff = (iBytes+iOffset)-qbPeek.getSize(); // We have to make our own buffer, since iBytes+nOffeset could be bigger // than pData. char *pTmp = new char[nDiff]; diff --git a/src/stable/server.cpp b/src/stable/server.cpp index 3f03a63..7c44c11 100644 --- a/src/stable/server.cpp +++ b/src/stable/server.cpp @@ -297,6 +297,7 @@ void Bu::Server::shutdown() void Bu::Server::closeClient( fd iSocket ) { + Bu::MutexLocker l( mClients ); BU_PROFILE_START("closeClient"); Bu::Client *pClient = hClients.get( iSocket ); Bu::Socket *pSocket = hSockets.get( iSocket ); @@ -421,7 +422,7 @@ void Bu::Server::IoWorker::handleRead( Client *pClient, Socket *pSocket ) { Bu::println("IoWorker::handleRead: exception, closing: %1").arg( e.what() ); close( pSocket ); - break; + return; } } BU_PROFILE_END("client.read"); @@ -492,6 +493,7 @@ void Bu::Server::ClientWorker::run() Bu::println("Processing input..."); pClient->processInput(); Bu::println("Processing input complete."); + Bu::println("*** ClientBuf: input: %1b, output: %2b").arg( pClient->getInputSize() ).arg( pClient->getOutputSize() ); delete pEv; } } -- cgit v1.2.3