In asio worker threads, catch and ignore exceptions thrown by asio
handlers. websocketspp code leaks boost exceptions from its handlers which would otherwise terminate the program
This commit is contained in:
parent
83a9e4d7c8
commit
9933f57dda
1 changed files with 20 additions and 1 deletions
21
src/asio.cpp
21
src/asio.cpp
|
|
@ -2,6 +2,7 @@
|
|||
#include <fc/thread/thread.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <fc/log/logger.hpp>
|
||||
#include <fc/exception/exception.hpp>
|
||||
|
||||
namespace fc {
|
||||
namespace asio {
|
||||
|
|
@ -102,7 +103,25 @@ namespace fc {
|
|||
asio_thread = new boost::thread( [=]()
|
||||
{
|
||||
fc::thread::current().set_name("asio");
|
||||
io->run();
|
||||
while (!io->stopped())
|
||||
{
|
||||
try
|
||||
{
|
||||
io->run();
|
||||
}
|
||||
catch (const fc::exception& e)
|
||||
{
|
||||
elog("Caught unhandled exception in asio service loop: ${e}", ("e", e));
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
elog("Caught unhandled exception in asio service loop: ${e}", ("e", e.what()));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
elog("Caught unhandled exception in asio service loop");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue