From 23761bade5e02e9ce30148a520d3c42bd8c380ff Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 13 May 2019 10:29:19 +0200 Subject: [PATCH 1/7] Dont inline generic pack/unpack to enable externalized serialization --- include/fc/io/raw.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 4e81b30..4247a7c 100755 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -524,11 +524,11 @@ namespace fc { template - inline void pack( Stream& s, const T& v ) { + void pack( Stream& s, const T& v ) { fc::raw::detail::if_reflected< typename fc::reflector::is_defined >::pack(s,v); } template - inline void unpack( Stream& s, T& v ) + void unpack( Stream& s, T& v ) { try { fc::raw::detail::if_reflected< typename fc::reflector::is_defined >::unpack(s,v); } FC_RETHROW_EXCEPTIONS( warn, "error unpacking ${type}", ("type",fc::get_typename::name() ) ) } From a94d110b5d4f526caf1f2a49aae7c5057b62dde2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 15 May 2019 12:48:06 +0200 Subject: [PATCH 2/7] Get rid of some inlines --- include/fc/io/raw.hpp | 1 - include/fc/network/ip.hpp | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index 4247a7c..7e5b5f1 100755 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -522,7 +522,6 @@ namespace fc { } - template void pack( Stream& s, const T& v ) { fc::raw::detail::if_reflected< typename fc::reflector::is_defined >::pack(s,v); diff --git a/include/fc/network/ip.hpp b/include/fc/network/ip.hpp index 5a1bd0c..1f23c5e 100755 --- a/include/fc/network/ip.hpp +++ b/include/fc/network/ip.hpp @@ -83,12 +83,12 @@ namespace fc { namespace raw { template - inline void pack( Stream& s, const ip::address& v ) + void pack( Stream& s, const ip::address& v ) { fc::raw::pack( s, uint32_t(v) ); } template - inline void unpack( Stream& s, ip::address& v ) + void unpack( Stream& s, ip::address& v ) { uint32_t _ip; fc::raw::unpack( s, _ip ); From 1893cb336c03c2f150f7bba0fb1c7cf607c50dc0 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 20 May 2019 21:38:15 +0200 Subject: [PATCH 3/7] Separate exception declaration and implementation --- include/fc/exception/exception.hpp | 117 +++++++++++++++++------------ src/exception.cpp | 19 +++++ 2 files changed, 86 insertions(+), 50 deletions(-) diff --git a/include/fc/exception/exception.hpp b/include/fc/exception/exception.hpp index 6fb66fa..24bd0f9 100755 --- a/include/fc/exception/exception.hpp +++ b/include/fc/exception/exception.hpp @@ -5,6 +5,7 @@ */ #include #include +#include #include #include #include @@ -222,81 +223,97 @@ namespace fc }(); \ -#define FC_DECLARE_DERIVED_EXCEPTION( TYPE, BASE, CODE, WHAT ) \ +#define FC_DECLARE_DERIVED_EXCEPTION( TYPE, BASE, CODE ) \ class TYPE : public BASE \ { \ public: \ enum code_enum { \ code_value = CODE, \ }; \ - explicit TYPE( int64_t code, const std::string& name_value, const std::string& what_value ) \ - :BASE( code, name_value, what_value ){} \ - explicit TYPE( fc::log_message&& m, int64_t code, const std::string& name_value, const std::string& what_value ) \ - :BASE( std::move(m), code, name_value, what_value ){} \ - explicit TYPE( fc::log_messages&& m, int64_t code, const std::string& name_value, const std::string& what_value )\ - :BASE( std::move(m), code, name_value, what_value ){}\ - explicit TYPE( const fc::log_messages& m, int64_t code, const std::string& name_value, const std::string& what_value )\ - :BASE( m, code, name_value, what_value ){}\ - TYPE( const std::string& what_value, const fc::log_messages& m ) \ - :BASE( m, CODE, BOOST_PP_STRINGIZE(TYPE), what_value ){} \ - TYPE( fc::log_message&& m ) \ - :BASE( fc::move(m), CODE, BOOST_PP_STRINGIZE(TYPE), WHAT ){}\ - TYPE( fc::log_messages msgs ) \ - :BASE( fc::move( msgs ), CODE, BOOST_PP_STRINGIZE(TYPE), WHAT ) {} \ - TYPE( const TYPE& c ) \ - :BASE(c){} \ - TYPE( const BASE& c ) \ - :BASE(c){} \ - TYPE():BASE(CODE, BOOST_PP_STRINGIZE(TYPE), WHAT){}\ + explicit TYPE( int64_t code, const std::string& name_value, const std::string& what_value ); \ + explicit TYPE( fc::log_message&& m, int64_t code, const std::string& name_value, const std::string& what_value ); \ + explicit TYPE( fc::log_messages&& m, int64_t code, const std::string& name_value, const std::string& what_value );\ + explicit TYPE( const fc::log_messages& m, int64_t code, const std::string& name_value, const std::string& what_value );\ + explicit TYPE( const std::string& what_value, const fc::log_messages& m ); \ + explicit TYPE( fc::log_message&& m ); \ + explicit TYPE( fc::log_messages msgs ); \ + TYPE( TYPE&& c ) = default; \ + TYPE( const TYPE& c ); \ + TYPE( const BASE& c ); \ + explicit TYPE();\ \ - virtual std::shared_ptr dynamic_copy_exception()const\ - { return std::make_shared( *this ); } \ - virtual NO_RETURN void dynamic_rethrow_exception()const \ - { if( code() == CODE ) throw *this;\ - else fc::exception::dynamic_rethrow_exception(); \ - } \ + virtual std::shared_ptr dynamic_copy_exception()const;\ + virtual NO_RETURN void dynamic_rethrow_exception()const; \ }; - #define FC_DECLARE_EXCEPTION( TYPE, CODE, WHAT ) \ - FC_DECLARE_DERIVED_EXCEPTION( TYPE, fc::exception, CODE, WHAT ) +#define FC_IMPLEMENT_DERIVED_EXCEPTION( TYPE, BASE, CODE, WHAT ) \ + TYPE::TYPE( int64_t code, const std::string& name_value, const std::string& what_value ) \ + : BASE( code, name_value, what_value ) {} \ + TYPE::TYPE( fc::log_message&& m, int64_t code, const std::string& name_value, const std::string& what_value ) \ + : BASE( std::move(m), code, name_value, what_value ) {} \ + TYPE::TYPE( fc::log_messages&& m, int64_t code, const std::string& name_value, const std::string& what_value ) \ + : BASE( std::move(m), code, name_value, what_value ) {} \ + TYPE::TYPE( const fc::log_messages& m, int64_t code, const std::string& name_value, const std::string& what_value ) \ + : BASE( m, code, name_value, what_value ) {} \ + TYPE::TYPE( const std::string& what_value, const fc::log_messages& m ) \ + : BASE( m, CODE, BOOST_PP_STRINGIZE(TYPE), what_value ) {} \ + TYPE::TYPE( fc::log_message&& m ) \ + : BASE( std::move(m), CODE, BOOST_PP_STRINGIZE(TYPE), WHAT ) {} \ + TYPE::TYPE( fc::log_messages msgs ) \ + : BASE( std::move( msgs ), CODE, BOOST_PP_STRINGIZE(TYPE), WHAT ) {} \ + TYPE::TYPE( const TYPE& c ) : BASE(c) {} \ + TYPE::TYPE( const BASE& c ) : BASE(c) {} \ + TYPE::TYPE() : BASE(CODE, BOOST_PP_STRINGIZE(TYPE), WHAT) {} \ + \ + std::shared_ptr TYPE::dynamic_copy_exception()const \ + { \ + return std::make_shared( *this ); \ + } \ + NO_RETURN void TYPE::dynamic_rethrow_exception()const \ + { \ + if( code() == CODE ) throw *this;\ + else fc::exception::dynamic_rethrow_exception(); \ + } + +#define FC_DECLARE_EXCEPTION( TYPE, CODE ) \ + FC_DECLARE_DERIVED_EXCEPTION( TYPE, fc::exception, CODE ) + +#define FC_IMPLEMENT_EXCEPTION( TYPE, CODE, WHAT ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( TYPE, fc::exception, CODE, WHAT ) - FC_DECLARE_EXCEPTION( timeout_exception, timeout_exception_code, "Timeout" ); - FC_DECLARE_EXCEPTION( file_not_found_exception, file_not_found_exception_code, "File Not Found" ); + FC_DECLARE_EXCEPTION( timeout_exception, timeout_exception_code ); + FC_DECLARE_EXCEPTION( file_not_found_exception, file_not_found_exception_code ); /** - * @brief report's parse errors + * @brief reports parse errors */ - FC_DECLARE_EXCEPTION( parse_error_exception, parse_error_exception_code, "Parse Error" ); - FC_DECLARE_EXCEPTION( invalid_arg_exception, invalid_arg_exception_code, "Invalid Argument" ); + FC_DECLARE_EXCEPTION( parse_error_exception, parse_error_exception_code ); + FC_DECLARE_EXCEPTION( invalid_arg_exception, invalid_arg_exception_code ); /** * @brief reports when a key, guid, or other item is not found. */ - FC_DECLARE_EXCEPTION( key_not_found_exception, key_not_found_exception_code, "Key Not Found" ); - FC_DECLARE_EXCEPTION( bad_cast_exception, bad_cast_exception_code, "Bad Cast" ); - FC_DECLARE_EXCEPTION( out_of_range_exception, out_of_range_exception_code, "Out of Range" ); + FC_DECLARE_EXCEPTION( key_not_found_exception, key_not_found_exception_code ); + FC_DECLARE_EXCEPTION( bad_cast_exception, bad_cast_exception_code ); + FC_DECLARE_EXCEPTION( out_of_range_exception, out_of_range_exception_code ); /** @brief if an operation is unsupported or not valid this may be thrown */ - FC_DECLARE_EXCEPTION( invalid_operation_exception, - invalid_operation_exception_code, - "Invalid Operation" ); + FC_DECLARE_EXCEPTION( invalid_operation_exception, invalid_operation_exception_code ); /** @brief if an host name can not be resolved this may be thrown */ - FC_DECLARE_EXCEPTION( unknown_host_exception, - unknown_host_exception_code, - "Unknown Host" ); + FC_DECLARE_EXCEPTION( unknown_host_exception, unknown_host_exception_code ); /** * @brief used to report a canceled Operation */ - FC_DECLARE_EXCEPTION( canceled_exception, canceled_exception_code, "Canceled" ); + FC_DECLARE_EXCEPTION( canceled_exception, canceled_exception_code ); /** * @brief used inplace of assert() to report violations of pre conditions. */ - FC_DECLARE_EXCEPTION( assert_exception, assert_exception_code, "Assert Exception" ); - FC_DECLARE_EXCEPTION( eof_exception, eof_exception_code, "End Of File" ); - FC_DECLARE_EXCEPTION( null_optional, null_optional_code, "null optional" ); - FC_DECLARE_EXCEPTION( aes_exception, aes_error_code, "AES error" ); - FC_DECLARE_EXCEPTION( overflow_exception, overflow_code, "Integer Overflow" ); - FC_DECLARE_EXCEPTION( underflow_exception, underflow_code, "Integer Underflow" ); - FC_DECLARE_EXCEPTION( divide_by_zero_exception, divide_by_zero_code, "Integer Divide By Zero" ); + FC_DECLARE_EXCEPTION( assert_exception, assert_exception_code ); + FC_DECLARE_EXCEPTION( eof_exception, eof_exception_code ); + FC_DECLARE_EXCEPTION( null_optional, null_optional_code ); + FC_DECLARE_EXCEPTION( aes_exception, aes_error_code ); + FC_DECLARE_EXCEPTION( overflow_exception, overflow_code ); + FC_DECLARE_EXCEPTION( underflow_exception, underflow_code ); + FC_DECLARE_EXCEPTION( divide_by_zero_exception, divide_by_zero_code ); std::string except_str(); diff --git a/src/exception.cpp b/src/exception.cpp index 0e0b956..0693f1a 100755 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -8,6 +8,25 @@ namespace fc { + FC_IMPLEMENT_EXCEPTION( timeout_exception, timeout_exception_code, "Timeout" ) + FC_IMPLEMENT_EXCEPTION( file_not_found_exception, file_not_found_exception_code, "File Not Found" ) + FC_IMPLEMENT_EXCEPTION( parse_error_exception, parse_error_exception_code, "Parse Error" ) + FC_IMPLEMENT_EXCEPTION( invalid_arg_exception, invalid_arg_exception_code, "Invalid Argument" ) + FC_IMPLEMENT_EXCEPTION( key_not_found_exception, key_not_found_exception_code, "Key Not Found" ) + FC_IMPLEMENT_EXCEPTION( bad_cast_exception, bad_cast_exception_code, "Bad Cast" ) + FC_IMPLEMENT_EXCEPTION( out_of_range_exception, out_of_range_exception_code, "Out of Range" ) + FC_IMPLEMENT_EXCEPTION( method_not_found_exception, method_not_found_exception_code, "Method Not Found" ); + FC_IMPLEMENT_EXCEPTION( invalid_operation_exception, invalid_operation_exception_code, "Invalid Operation" ) + FC_IMPLEMENT_EXCEPTION( unknown_host_exception, unknown_host_exception_code, "Unknown Host" ) + FC_IMPLEMENT_EXCEPTION( canceled_exception, canceled_exception_code, "Canceled" ) + FC_IMPLEMENT_EXCEPTION( assert_exception, assert_exception_code, "Assert Exception" ) + FC_IMPLEMENT_EXCEPTION( eof_exception, eof_exception_code, "End Of File" ) + FC_IMPLEMENT_EXCEPTION( null_optional, null_optional_code, "null optional" ) + FC_IMPLEMENT_EXCEPTION( aes_exception, aes_error_code, "AES error" ) + FC_IMPLEMENT_EXCEPTION( overflow_exception, overflow_code, "Integer Overflow" ) + FC_IMPLEMENT_EXCEPTION( underflow_exception, underflow_code, "Integer Underflow" ) + FC_IMPLEMENT_EXCEPTION( divide_by_zero_exception, divide_by_zero_code, "Integer Divide By Zero" ) + FC_REGISTER_EXCEPTIONS( (timeout_exception) (file_not_found_exception) (parse_error_exception) From 2343ab74f35e7188df0c63ad502b0ee9e7574310 Mon Sep 17 00:00:00 2001 From: gladcow Date: Thu, 19 Sep 2019 18:21:50 +0300 Subject: [PATCH 4/7] fix compilation errors --- include/fc/network/ip.hpp | 2 +- src/exception.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/fc/network/ip.hpp b/include/fc/network/ip.hpp index 1f23c5e..8c5f548 100755 --- a/include/fc/network/ip.hpp +++ b/include/fc/network/ip.hpp @@ -113,7 +113,7 @@ namespace fc { } } // namespace fc -FC_REFLECT_TYPENAME( fc::ip::address ) +FC_REFLECT_EMPTY( fc::ip::address ) FC_REFLECT_TYPENAME( fc::ip::endpoint ) namespace std { diff --git a/src/exception.cpp b/src/exception.cpp index 0693f1a..a7fc4fe 100755 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -15,7 +15,6 @@ namespace fc FC_IMPLEMENT_EXCEPTION( key_not_found_exception, key_not_found_exception_code, "Key Not Found" ) FC_IMPLEMENT_EXCEPTION( bad_cast_exception, bad_cast_exception_code, "Bad Cast" ) FC_IMPLEMENT_EXCEPTION( out_of_range_exception, out_of_range_exception_code, "Out of Range" ) - FC_IMPLEMENT_EXCEPTION( method_not_found_exception, method_not_found_exception_code, "Method Not Found" ); FC_IMPLEMENT_EXCEPTION( invalid_operation_exception, invalid_operation_exception_code, "Invalid Operation" ) FC_IMPLEMENT_EXCEPTION( unknown_host_exception, unknown_host_exception_code, "Unknown Host" ) FC_IMPLEMENT_EXCEPTION( canceled_exception, canceled_exception_code, "Canceled" ) From 2f79730323e2d6c1137072d6a7452bb28f1020bc Mon Sep 17 00:00:00 2001 From: satyakoneru Date: Wed, 6 Nov 2019 11:18:04 +0000 Subject: [PATCH 5/7] GRPH134-Witness High CPU Issue, websocket changes --- include/fc/rpc/websocket_api.hpp | 4 +-- src/rpc/websocket_api.cpp | 44 ++++++++++++-------------------- tests/api.cpp | 4 +-- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/include/fc/rpc/websocket_api.hpp b/include/fc/rpc/websocket_api.hpp index 61348ce..ebb6fe7 100755 --- a/include/fc/rpc/websocket_api.hpp +++ b/include/fc/rpc/websocket_api.hpp @@ -10,7 +10,7 @@ namespace fc { namespace rpc { class websocket_api_connection : public api_connection { public: - websocket_api_connection( const std::shared_ptr &c, uint32_t max_conversion_depth ); + websocket_api_connection( fc::http::websocket_connection& c, uint32_t max_conversion_depth ); ~websocket_api_connection(); virtual variant send_call( @@ -29,7 +29,7 @@ namespace fc { namespace rpc { const std::string& message, bool send_message = true ); - std::shared_ptr _connection; + fc::http::websocket_connection& _connection; fc::rpc::state _rpc_state; }; diff --git a/src/rpc/websocket_api.cpp b/src/rpc/websocket_api.cpp index d9b9cad..ae4e26e 100755 --- a/src/rpc/websocket_api.cpp +++ b/src/rpc/websocket_api.cpp @@ -7,10 +7,9 @@ websocket_api_connection::~websocket_api_connection() { } -websocket_api_connection::websocket_api_connection( const std::shared_ptr& c, uint32_t max_depth ) +websocket_api_connection::websocket_api_connection( fc::http::websocket_connection& c, uint32_t max_depth ) : api_connection(max_depth),_connection(c) { - FC_ASSERT( c ); _rpc_state.add_method( "call", [this]( const variants& args ) -> variant { FC_ASSERT( args.size() == 3 && args[2].is_array() ); @@ -48,9 +47,9 @@ websocket_api_connection::websocket_api_connection( const std::shared_ptrreceive_call( 0, method_name, args ); } ); - _connection->on_message_handler( [&]( const std::string& msg ){ on_message(msg,true); } ); - _connection->on_http_handler( [&]( const std::string& msg ){ return on_message(msg,false); } ); - _connection->closed.connect( [this](){ closed(); } ); + _connection.on_message_handler( [&]( const std::string& msg ){ on_message(msg,true); } ); + _connection.on_http_handler( [&]( const std::string& msg ){ return on_message(msg,false); } ); + _connection.closed.connect( [this](){ closed(); } ); } variant websocket_api_connection::send_call( @@ -58,40 +57,29 @@ variant websocket_api_connection::send_call( string method_name, variants args /* = variants() */ ) { - if( _connection ) - { - auto request = _rpc_state.start_remote_call( "call", {api_id, std::move(method_name), std::move(args) } ); - _connection->send_message( fc::json::to_string(fc::variant(request, _max_conversion_depth), + auto request = _rpc_state.start_remote_call( "call", {api_id, std::move(method_name), std::move(args) } ); + _connection.send_message( fc::json::to_string(fc::variant(request, _max_conversion_depth), fc::json::stringify_large_ints_and_doubles, _max_conversion_depth ) ); - return _rpc_state.wait_for_response( *request.id ); - } - return variant(); + return _rpc_state.wait_for_response( *request.id ); } variant websocket_api_connection::send_callback( uint64_t callback_id, variants args /* = variants() */ ) { - if( _connection ) - { - auto request = _rpc_state.start_remote_call( "callback", {callback_id, std::move(args) } ); - _connection->send_message( fc::json::to_string(fc::variant(request, _max_conversion_depth), + auto request = _rpc_state.start_remote_call( "callback", {callback_id, std::move(args) } ); + _connection.send_message( fc::json::to_string(fc::variant(request, _max_conversion_depth), fc::json::stringify_large_ints_and_doubles, _max_conversion_depth ) ); - return _rpc_state.wait_for_response( *request.id ); - } - return variant(); + return _rpc_state.wait_for_response( *request.id ); } void websocket_api_connection::send_notice( uint64_t callback_id, variants args /* = variants() */ ) { - if( _connection ) - { - fc::rpc::request req{ optional(), "notice", {callback_id, std::move(args)}}; - _connection->send_message( fc::json::to_string(fc::variant(req, _max_conversion_depth), + fc::rpc::request req{ optional(), "notice", {callback_id, std::move(args)}}; + _connection.send_message( fc::json::to_string(fc::variant(req, _max_conversion_depth), fc::json::stringify_large_ints_and_doubles, _max_conversion_depth ) ); - } } std::string websocket_api_connection::on_message( @@ -129,8 +117,8 @@ std::string websocket_api_connection::on_message( if( call.id ) { auto reply = fc::json::to_string( response( *call.id, result, "2.0" ), fc::json::stringify_large_ints_and_doubles, _max_conversion_depth ); - if( send_message && _connection ) - _connection->send_message( reply ); + if( send_message ) + _connection.send_message( reply ); return reply; } } @@ -147,8 +135,8 @@ std::string websocket_api_connection::on_message( auto reply = fc::json::to_string( variant(response( *call.id, error_object{ 1, optexcept->to_string(), fc::variant(*optexcept, _max_conversion_depth)}, "2.0" ), _max_conversion_depth ), fc::json::stringify_large_ints_and_doubles, _max_conversion_depth ); - if( send_message && _connection ) - _connection->send_message( reply ); + if( send_message ) + _connection.send_message( reply ); return reply; } diff --git a/tests/api.cpp b/tests/api.cpp index fbe42f2..e0514c3 100755 --- a/tests/api.cpp +++ b/tests/api.cpp @@ -61,7 +61,7 @@ int main( int argc, char** argv ) fc::http::websocket_server server; server.on_connection([&]( const websocket_connection_ptr& c ){ - auto wsc = std::make_shared(c, MAX_DEPTH); + auto wsc = std::make_shared(*c, MAX_DEPTH); auto login = std::make_shared(); login->calc = calc_api; wsc->register_api(fc::api(login)); @@ -76,7 +76,7 @@ int main( int argc, char** argv ) try { fc::http::websocket_client client; auto con = client.connect( "ws://localhost:8090" ); - auto apic = std::make_shared(con, MAX_DEPTH); + auto apic = std::make_shared(*con, MAX_DEPTH); auto remote_login_api = apic->get_remote_api(); auto remote_calc = remote_login_api->get_calc(); remote_calc->on_result( []( uint32_t r ) { elog( "callback result ${r}", ("r",r) ); } ); From d16ee316c9a15eafe5b25d2997533116c03bbd2c Mon Sep 17 00:00:00 2001 From: Sandip Patel Date: Tue, 12 Nov 2019 12:08:29 +0530 Subject: [PATCH 6/7] Fix memory leak. Not all tasks are deleted in thread_d dtor --- src/thread/thread.cpp | 6 +++++- src/thread/thread_d.hpp | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/thread/thread.cpp b/src/thread/thread.cpp index 7b899bb..25ba77c 100755 --- a/src/thread/thread.cpp +++ b/src/thread/thread.cpp @@ -110,7 +110,7 @@ namespace fc { thread::~thread() { //wlog( "my ${n}", ("n",name()) ); - if( my ) + if( my && is_running() ) { // wlog( "calling quit() on ${n}",("n",my->name) ); quit(); // deletes `my` @@ -333,6 +333,10 @@ namespace fc { void thread::async_task( task_base* t, const priority& p, const time_point& tp ) { assert(my); + if( !is_running() ) + { + FC_THROW_EXCEPTION( canceled_exception, "Thread is not running."); + } t->_when = tp; // slog( "when %lld", t->_when.time_since_epoch().count() ); // slog( "delay %lld", (tp - fc::time_point::now()).count() ); diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 74b59d3..8e36b14 100755 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -42,7 +42,14 @@ namespace fc { delete current; fc::context* temp; for (fc::context* ready_context : ready_heap) - delete ready_context; + { + if (ready_context->cur_task) + { + ready_context->cur_task->release(); + ready_context->cur_task = nullptr; + } + delete ready_context; + } ready_heap.clear(); while (blocked) { @@ -509,10 +516,10 @@ namespace fc { next->_set_active_context( current ); current->cur_task = next; - next->run(); + fc::shared_ptr next_ptr(next); + next_ptr->run(); current->cur_task = 0; - next->_set_active_context(0); - next->release(); + next_ptr->_set_active_context(0); current->reinitialize(); } From 4beb698268565780ffaae55f165dd64d5611c643 Mon Sep 17 00:00:00 2001 From: satyakoneru Date: Mon, 19 Aug 2019 16:51:50 +0000 Subject: [PATCH 7/7] GRPH-46-AddQuitCommandToCliWallet - Add Quit command to CLI Wallet --- src/rpc/cli.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index d3070fb..4957fc3 100755 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -121,6 +121,11 @@ void cli::run() catch ( const fc::exception& e ) { std::cout << e.to_detail_string() << "\n"; + + if (e.code() == fc::canceled_exception_code) + { + break; + } } } }