Do everything required to stop the server in ::stop().
[dcpomatic.git] / src / lib / server.cc
index c1be5735e9bb0be7db25831ebab9f44641ec1f3c..6e3781dca4fce763d78d023997b92cd18134acd3 100644 (file)
@@ -41,13 +41,7 @@ Server::Server (int port, int timeout)
 
 Server::~Server ()
 {
-       {
-               boost::mutex::scoped_lock lm (_mutex);
-               _terminate = true;
-       }
-
-       _acceptor.close ();
-       stop ();
+       stop();
 }
 
 
@@ -89,5 +83,11 @@ 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 ();
        _io_service.stop ();
 }