This commit is contained in:
Daniel Larimer 2015-07-23 13:17:03 -04:00
commit 2808c02cc7
2 changed files with 31 additions and 22 deletions

View file

@ -106,7 +106,7 @@ namespace fc {
}); });
} }
~default_io_service_scope() void cleanup()
{ {
delete the_work; delete the_work;
io->stop(); io->stop();
@ -114,9 +114,16 @@ namespace fc {
delete io; delete io;
delete asio_thread; delete asio_thread;
} }
~default_io_service_scope()
{}
}; };
/// If cleanup is true, do not use the return value; it is a null reference
boost::asio::io_service& default_io_service(bool cleanup) { boost::asio::io_service& default_io_service(bool cleanup) {
static default_io_service_scope fc_asio_service; static default_io_service_scope fc_asio_service;
if (cleanup)
fc_asio_service.cleanup();
return *fc_asio_service.io; return *fc_asio_service.io;
} }

View file

@ -255,6 +255,7 @@ namespace fc { namespace http {
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" );
fc::asio::default_io_service(true);
} }
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;
@ -359,6 +360,7 @@ namespace fc { namespace http {
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" );
fc::asio::default_io_service(true);
} }
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;