aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/multiserver.cpp5
-rw-r--r--src/multiserver.h2
-rw-r--r--src/server.cpp28
-rw-r--r--src/server.h2
4 files changed, 28 insertions, 9 deletions
diff --git a/src/multiserver.cpp b/src/multiserver.cpp
index ad7855a..dd2da3b 100644
--- a/src/multiserver.cpp
+++ b/src/multiserver.cpp
@@ -43,3 +43,8 @@ void Bu::MultiServer::onClosedConnection( Bu::Client *pClient )
43 delete pClient->getProtocol(); 43 delete pClient->getProtocol();
44} 44}
45 45
46void Bu::MultiServer::shutdown()
47{
48 Bu::Server::shutdown();
49}
50
diff --git a/src/multiserver.h b/src/multiserver.h
index 2938e0b..fc8305f 100644
--- a/src/multiserver.h
+++ b/src/multiserver.h
@@ -45,6 +45,8 @@ namespace Bu
45 virtual void onNewConnection( Client *pClient, int nPort ); 45 virtual void onNewConnection( Client *pClient, int nPort );
46 virtual void onClosedConnection( Client *pClient ); 46 virtual void onClosedConnection( Client *pClient );
47 47
48 void shutdown();
49
48 private: 50 private:
49 Bu::Hash<int, Protocol *(*)()> hProtos; 51 Bu::Hash<int, Protocol *(*)()> hProtos;
50 }; 52 };
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
24Bu::Server::~Server() 24Bu::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
37void Bu::Server::addPort( int nPort, int nPoolSize ) 29void Bu::Server::addPort( int nPort, int nPoolSize )
@@ -185,3 +177,21 @@ void Bu::Server::tick()
185 } 177 }
186} 178}
187 179
180void 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
diff --git a/src/server.h b/src/server.h
index f4b2da6..d83c346 100644
--- a/src/server.h
+++ b/src/server.h
@@ -68,6 +68,8 @@ namespace Bu
68 virtual void onNewConnection( Client *pClient, int nPort )=0; 68 virtual void onNewConnection( Client *pClient, int nPort )=0;
69 virtual void onClosedConnection( Client *pClient )=0; 69 virtual void onClosedConnection( Client *pClient )=0;
70 70
71 void shutdown();
72
71 private: 73 private:
72 class SrvClientLink : public Bu::ClientLink 74 class SrvClientLink : public Bu::ClientLink
73 { 75 {