diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 2d446e5..db5ae9b 100755 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -434,8 +434,9 @@ namespace fc { namespace http { _client_thread.async( [&](){ if( _connection ) _connection->closed(); _connection.reset(); } ).wait(); if( _connected && !_connected->ready() ) _connected->set_exception( exception_ptr( new FC_EXCEPTION( exception, "${message}", ("message",message)) ) ); - if( _closed ) - _closed->set_value(); + //if( _closed && !_closed->ready() ) + // _closed->set_value(); + _failed = true; }); _client.init_asio( &fc::asio::default_io_service() ); @@ -447,11 +448,11 @@ namespace fc { namespace http { _connection->close(0, "client closed"); _connection.reset(); } - if( _closed ) + if( _closed && !_failed) _closed->wait(); } - + bool _failed = false; fc::promise::ptr _connected; fc::promise::ptr _closed; fc::thread& _client_thread; diff --git a/tests/thread/task_cancel.cpp b/tests/thread/task_cancel.cpp index 3435f39..cc26e4f 100755 --- a/tests/thread/task_cancel.cpp +++ b/tests/thread/task_cancel.cpp @@ -191,11 +191,8 @@ BOOST_AUTO_TEST_CASE( cleanup_cancelled_task ) { fc::usleep(fc::seconds(5)); BOOST_TEST_MESSAGE("Finsihed usleep in async task, leaving the task's functor"); - } - catch (...) - { - BOOST_TEST_MESSAGE("Caught exception in async task, leaving the task's functor"); - } + } FC_CAPTURE_AND_LOG( (some_string) ); + }, "test_task"); std::weak_ptr weak_string_ptr(some_string); some_string.reset();