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" );
|
wlog( "unknown connection closed" );
|
||||||
}
|
}
|
||||||
|
if( _connections.empty() && _closed )
|
||||||
|
_closed->set_value();
|
||||||
}).wait();
|
}).wait();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -244,6 +246,8 @@ namespace fc { namespace http {
|
||||||
{
|
{
|
||||||
wlog( "unknown connection failed" );
|
wlog( "unknown connection failed" );
|
||||||
}
|
}
|
||||||
|
if( _connections.empty() && _closed )
|
||||||
|
_closed->set_value();
|
||||||
}).wait();
|
}).wait();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -252,9 +256,15 @@ namespace fc { namespace http {
|
||||||
{
|
{
|
||||||
if( _server.is_listening() )
|
if( _server.is_listening() )
|
||||||
_server.stop_listening();
|
_server.stop_listening();
|
||||||
|
|
||||||
|
if( _connections.size() )
|
||||||
|
_closed = new fc::promise<void>();
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
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