diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-06-14 19:50:41 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-06-23 19:51:28 +0200 |
| commit | 321380eeb8a9ba4853a982558c9076d26aafdf82 (patch) | |
| tree | 0a45b630eae75647569bab34b858e0513898a60f /src | |
| parent | dbab45a8358d8a48043718872f2649fc24b1d9ef (diff) | |
Close socket when stopping the server.
Otherwise if we're calling e.g. Socket::run() the server's run() will
not terminate on stop().
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/server.cc | 5 | ||||
| -rw-r--r-- | src/lib/server.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/server.cc b/src/lib/server.cc index 6e3781dca..359234044 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -75,6 +75,8 @@ Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code cons return; } + _socket = socket; + handle (socket); start_accept (); } @@ -89,5 +91,8 @@ Server::stop () } _acceptor.close (); + if (auto s = _socket.lock()) { + s->close(); + } _io_service.stop (); } diff --git a/src/lib/server.h b/src/lib/server.h index 0b1950aa7..7e42f6cbd 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -57,6 +57,7 @@ private: boost::asio::io_service _io_service; boost::asio::ip::tcp::acceptor _acceptor; int _timeout; + std::weak_ptr<Socket> _socket; }; |
