Refactor destructor of websocket_server_impl
This commit is contained in:
parent
c55b1fde3c
commit
4dd1319a9e
1 changed files with 6 additions and 4 deletions
|
|
@ -361,13 +361,15 @@ namespace fc { namespace http {
|
||||||
// in another thread, perhaps we need to wait for them (especially the one in set_open_handler)
|
// in another thread, perhaps we need to wait for them (especially the one in set_open_handler)
|
||||||
// being processed. Otherwise `_closed.wait()` may hang.
|
// being processed. Otherwise `_closed.wait()` may hang.
|
||||||
if( _connections.size() )
|
if( _connections.size() )
|
||||||
|
{
|
||||||
_closed = promise<void>::create();
|
_closed = promise<void>::create();
|
||||||
|
|
||||||
auto cpy_con = _connections;
|
auto cpy_con = _connections;
|
||||||
for( auto item : cpy_con )
|
for( auto& item : cpy_con )
|
||||||
_server.close( item.first, 0, "server exit" );
|
_server.close( item.first, 0, "server exit" );
|
||||||
|
|
||||||
if( _closed ) _closed->wait();
|
_closed->wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<connection_hdl, websocket_connection_ptr, std::owner_less<connection_hdl> > con_map;
|
typedef std::map<connection_hdl, websocket_connection_ptr, std::owner_less<connection_hdl> > con_map;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue