Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
When nodeos lost connection to amqp it would block on exit. Add bette…
Browse files Browse the repository at this point in the history
…r handling of stop() during shutdown.
  • Loading branch information
heifner committed Mar 5, 2021
1 parent edabd8a commit 284eb62
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libraries/amqp/include/eosio/amqp/amqp_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,18 @@ class amqp {
std::promise<void> stop_promise;
auto future = stop_promise.get_future();
boost::asio::post( *handler_->amqp_strand(), [&]() {
if( channel_ ) {
if( channel_ && channel_->usable() ) {
auto& cb = channel_->close();
cb.onFinalize( [&]() {
stop_promise.set_value();
try {
stop_promise.set_value();
} catch(...) {}
} );
cb.onError( [&](const char* message) {
elog( "Error on stop: ${m}", ("m", message) );
try {
stop_promise.set_value();
} catch(...) {}
} );
} else {
stop_promise.set_value();
Expand Down

0 comments on commit 284eb62

Please sign in to comment.