summaryrefslogtreecommitdiff
path: root/src/lib/server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/server.cc')
-rw-r--r--src/lib/server.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/server.cc b/src/lib/server.cc
index c1be5735e..359234044 100644
--- a/src/lib/server.cc
+++ b/src/lib/server.cc
@@ -41,13 +41,7 @@ Server::Server (int port, int timeout)
Server::~Server ()
{
- {
- boost::mutex::scoped_lock lm (_mutex);
- _terminate = true;
- }
-
- _acceptor.close ();
- stop ();
+ stop();
}
@@ -81,6 +75,8 @@ Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code cons
return;
}
+ _socket = socket;
+
handle (socket);
start_accept ();
}
@@ -89,5 +85,14 @@ Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code cons
void
Server::stop ()
{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _terminate = true;
+ }
+
+ _acceptor.close ();
+ if (auto s = _socket.lock()) {
+ s->close();
+ }
_io_service.stop ();
}