From 86f9fbefa58d91e151190c969216c751573bc664 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 4 Oct 2007 10:46:46 +0000 Subject: Discovered that the Bu::Client::disconnect() function didn't do anything. That has been fixed, it now safely disconnects after emptying the Client's outgoing buffer. Added some more helpers to Bu::FString. Added the beginings of ProtocolHttp using a new method for processing protocols that's based more strongly on an NFA state machine, this makes sense, but I never had the desire to actually try implementing it before. It's working pretty well. --- src/server.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 53b4301..29d4822 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -74,12 +74,26 @@ void Bu::Server::scan() } } + Bu::List lDelete; // Now we just try to write all the pending data on all the sockets. // this could be done better eventually, if we care about the socket // wanting to accept writes (using a select). for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ ) { (*i)->processOutput(); + if( (*i)->wantsDisconnect() ) + { + lDelete.append( i.getKey() ); + } + } + + for( Bu::List::iterator i = lDelete.begin(); i != lDelete.end(); i++ ) + { + Client *pClient = hClients.get( *i ); + onClosedConnection( pClient ); + pClient->close(); + hClients.erase( *i ); + FD_CLR( *i, &fdActive ); } } -- cgit v1.2.3