diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-03-12 16:21:25 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-03-12 16:21:25 +0000 |
commit | 14a460c60b162aefaf1798c71ac790ad574e739f (patch) | |
tree | 2e9920d5f671a55f5ec380787eca34c62f97afef /src/server.cpp | |
parent | 3667cec1f612e6a37479f99bd1fa23d92af7cff7 (diff) | |
download | libbu++-14a460c60b162aefaf1798c71ac790ad574e739f.tar.gz libbu++-14a460c60b162aefaf1798c71ac790ad574e739f.tar.bz2 libbu++-14a460c60b162aefaf1798c71ac790ad574e739f.tar.xz libbu++-14a460c60b162aefaf1798c71ac790ad574e739f.zip |
The server and multiserver now support a shutdown() function which calls
onCloseConnection on each client before cleaning it up, allowing for smooth
cleanup. Later we may want to add a nicer version with a timeout for pending
data to be transmitted and the like. This one is pretty harsh.
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/server.cpp b/src/server.cpp index 8bc1767..80ed509 100644 --- a/src/server.cpp +++ b/src/server.cpp | |||
@@ -23,15 +23,7 @@ Bu::Server::Server() : | |||
23 | 23 | ||
24 | Bu::Server::~Server() | 24 | Bu::Server::~Server() |
25 | { | 25 | { |
26 | for( SrvHash::iterator i = hServers.begin(); i != hServers.end(); i++ ) | 26 | shutdown(); |
27 | { | ||
28 | delete *i; | ||
29 | } | ||
30 | |||
31 | for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ ) | ||
32 | { | ||
33 | delete *i; | ||
34 | } | ||
35 | } | 27 | } |
36 | 28 | ||
37 | void Bu::Server::addPort( int nPort, int nPoolSize ) | 29 | void Bu::Server::addPort( int nPort, int nPoolSize ) |
@@ -185,3 +177,21 @@ void Bu::Server::tick() | |||
185 | } | 177 | } |
186 | } | 178 | } |
187 | 179 | ||
180 | void Bu::Server::shutdown() | ||
181 | { | ||
182 | for( SrvHash::iterator i = hServers.begin(); i != hServers.end(); i++ ) | ||
183 | { | ||
184 | delete *i; | ||
185 | } | ||
186 | |||
187 | hServers.clear(); | ||
188 | |||
189 | for( ClientHash::iterator i = hClients.begin(); i != hClients.end(); i++ ) | ||
190 | { | ||
191 | onClosedConnection( *i ); | ||
192 | delete *i; | ||
193 | } | ||
194 | |||
195 | hClients.clear(); | ||
196 | } | ||
197 | |||