From 7beaff764ccdd06f0e6852fc8091ee61189b1a2b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Dec 2008 18:56:47 +0000 Subject: Strange, I never actually made any of the server code clean up behind itself in the deconstructors. When you deleted a server it wouldn't close it's sockets. We never noticed because servers normally last the entire lifetime of the program they're in. --- src/server.cpp | 9 +++++++++ src/server.h | 3 ++- src/serversocket.cpp | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/server.cpp b/src/server.cpp index 981da0c..eb85997 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -21,6 +21,15 @@ Bu::Server::Server() : Bu::Server::~Server() { + for( SrvHash::iterator i = hServers.begin(); i != hServers.end(); i++ ) + { + delete *i; + } + + for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ ) + { + delete *i; + } } void Bu::Server::addPort( int nPort, int nPoolSize ) diff --git a/src/server.h b/src/server.h index c4ad4b9..13f5084 100644 --- a/src/server.h +++ b/src/server.h @@ -86,7 +86,8 @@ namespace Bu int nTimeoutSec; int nTimeoutUSec; fd_set fdActive; - Hash hServers; + typedef Hash SrvHash; + SrvHash hServers; typedef Hash ClientHash; ClientHash hClients; }; diff --git a/src/serversocket.cpp b/src/serversocket.cpp index 1908a8a..946d0d3 100644 --- a/src/serversocket.cpp +++ b/src/serversocket.cpp @@ -66,6 +66,7 @@ Bu::ServerSocket::ServerSocket(const FString &sAddr,int nPort, int nPoolSize) : Bu::ServerSocket::~ServerSocket() { + ::close( nServer ); } void Bu::ServerSocket::startServer( struct sockaddr_in &name, int nPoolSize ) -- cgit v1.2.3