Attempt to fix tests
An exception was getting thrown during the handshake process that wasn't properly being thrown. Since poll() only ran during the handshake, I've moved the handling in that case to wait_for_handshake().
This commit is contained in:
parent
1e9d649271
commit
65937511bf
1 changed files with 22 additions and 2 deletions
|
@ -78,7 +78,17 @@ wesnothd_connection::wesnothd_connection(const std::string& host, const std::str
|
|||
|
||||
// Starts the worker thread. Do this *after* the above async_resolve call or it will just exit immediately!
|
||||
worker_thread_ = std::thread([this]() {
|
||||
io_service_.run();
|
||||
try {
|
||||
io_service_.run();
|
||||
} catch(const boost::system::system_error& err) {
|
||||
try {
|
||||
// Attempt to pass the exception on to the handshake promise.
|
||||
handshake_finished_.set_exception(std::current_exception());
|
||||
} catch(const std::future_error&) {
|
||||
// Handshake already complete. Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
LOG_NW << "wesnothd_connection::io_service::run() returned\n";
|
||||
});
|
||||
|
||||
|
@ -165,7 +175,17 @@ void wesnothd_connection::wait_for_handshake()
|
|||
{
|
||||
MPTEST_LOG;
|
||||
LOG_NW << "Waiting for handshake" << std::endl;
|
||||
handshake_finished_.get_future().wait();
|
||||
|
||||
try {
|
||||
handshake_finished_.get_future().get();
|
||||
} catch(const boost::system::system_error& err) {
|
||||
if(err.code() == boost::asio::error::operation_aborted || err.code() == boost::asio::error::eof) {
|
||||
return;
|
||||
}
|
||||
|
||||
WRN_NW << __func__ << " Rethrowing: " << err.code() << "\n";
|
||||
throw error(err.code());
|
||||
}
|
||||
}
|
||||
|
||||
// main thread
|
||||
|
|
Loading…
Add table
Reference in a new issue