Fix crash on exit
This commit is contained in:
parent
cb006ba03c
commit
9c868b3927
1 changed files with 11 additions and 1 deletions
|
|
@ -228,6 +228,8 @@ namespace fc { namespace http {
|
|||
{
|
||||
wlog( "unknown connection closed" );
|
||||
}
|
||||
if( _connections.empty() && _closed )
|
||||
_closed->set_value();
|
||||
}).wait();
|
||||
});
|
||||
|
||||
|
|
@ -244,17 +246,25 @@ namespace fc { namespace http {
|
|||
{
|
||||
wlog( "unknown connection failed" );
|
||||
}
|
||||
if( _connections.empty() && _closed )
|
||||
_closed->set_value();
|
||||
}).wait();
|
||||
}
|
||||
});
|
||||
}
|
||||
~websocket_server_impl()
|
||||
{
|
||||
{
|
||||
if( _server.is_listening() )
|
||||
_server.stop_listening();
|
||||
|
||||
if( _connections.size() )
|
||||
_closed = new fc::promise<void>();
|
||||
|
||||
auto cpy_con = _connections;
|
||||
for( auto item : cpy_con )
|
||||
_server.close( item.first, 0, "server exit" );
|
||||
|
||||
if( _closed ) _closed->wait();
|
||||
}
|
||||
|
||||
typedef std::map<connection_hdl, websocket_connection_ptr,std::owner_less<connection_hdl> > con_map;
|
||||
|
|
|
|||
Loading…
Reference in a new issue