prevents data race in server.stop() - see bug #1661

This commit is contained in:
moe 2021-12-25 22:48:03 +01:00
parent 02e6cad121
commit d9ddb73a74
1 changed files with 7 additions and 1 deletions

View File

@ -188,7 +188,13 @@ void server::start_accept(tcp::acceptor &acceptor, serve_mux &mux) {
void server::stop() {
for (auto &acceptor : acceptors_) {
acceptor.close();
std::promise<void> promise;
GET_IO_SERVICE ( acceptor ).dispatch ( [&acceptor, &promise]() {
boost::system::error_code ignored_ec;
acceptor.close ( ignored_ec );
promise.set_value();
} );
promise.get_future().get();
}
io_service_pool_.stop();
}