fix cores: don't use promise in websocket when failure, use FC_CAPTURE_AND_LOG in cleanup_cancelled_task
This commit is contained in:
parent
30296957f7
commit
a2221e2054
2 changed files with 7 additions and 9 deletions
|
|
@ -434,8 +434,9 @@ namespace fc { namespace http {
|
||||||
_client_thread.async( [&](){ if( _connection ) _connection->closed(); _connection.reset(); } ).wait();
|
_client_thread.async( [&](){ if( _connection ) _connection->closed(); _connection.reset(); } ).wait();
|
||||||
if( _connected && !_connected->ready() )
|
if( _connected && !_connected->ready() )
|
||||||
_connected->set_exception( exception_ptr( new FC_EXCEPTION( exception, "${message}", ("message",message)) ) );
|
_connected->set_exception( exception_ptr( new FC_EXCEPTION( exception, "${message}", ("message",message)) ) );
|
||||||
if( _closed )
|
//if( _closed && !_closed->ready() )
|
||||||
_closed->set_value();
|
// _closed->set_value();
|
||||||
|
_failed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
_client.init_asio( &fc::asio::default_io_service() );
|
_client.init_asio( &fc::asio::default_io_service() );
|
||||||
|
|
@ -447,11 +448,11 @@ namespace fc { namespace http {
|
||||||
_connection->close(0, "client closed");
|
_connection->close(0, "client closed");
|
||||||
_connection.reset();
|
_connection.reset();
|
||||||
}
|
}
|
||||||
if( _closed )
|
if( _closed && !_failed)
|
||||||
_closed->wait();
|
_closed->wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _failed = false;
|
||||||
fc::promise<void>::ptr _connected;
|
fc::promise<void>::ptr _connected;
|
||||||
fc::promise<void>::ptr _closed;
|
fc::promise<void>::ptr _closed;
|
||||||
fc::thread& _client_thread;
|
fc::thread& _client_thread;
|
||||||
|
|
|
||||||
|
|
@ -191,11 +191,8 @@ BOOST_AUTO_TEST_CASE( cleanup_cancelled_task )
|
||||||
{
|
{
|
||||||
fc::usleep(fc::seconds(5));
|
fc::usleep(fc::seconds(5));
|
||||||
BOOST_TEST_MESSAGE("Finsihed usleep in async task, leaving the task's functor");
|
BOOST_TEST_MESSAGE("Finsihed usleep in async task, leaving the task's functor");
|
||||||
}
|
} FC_CAPTURE_AND_LOG( (some_string) );
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
BOOST_TEST_MESSAGE("Caught exception in async task, leaving the task's functor");
|
|
||||||
}
|
|
||||||
}, "test_task");
|
}, "test_task");
|
||||||
std::weak_ptr<std::string> weak_string_ptr(some_string);
|
std::weak_ptr<std::string> weak_string_ptr(some_string);
|
||||||
some_string.reset();
|
some_string.reset();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue