Fix for unit test ipc.asynchronous (#3964)
It can fail due to the callback trying to access a destroyed node. The real problem is likely larger than this little fix and related to the chaotic way the node shuts down. Leaving the larger fix for another time, priorities...
This commit is contained in:
parent
e1d9cb0ba4
commit
5fcb8e09a0
1 changed files with 11 additions and 4 deletions
|
|
@ -511,23 +511,30 @@ public:
|
|||
// Prepare the next session
|
||||
auto new_session (std::make_shared<session<SOCKET_TYPE>> (server, context (), config_transport));
|
||||
|
||||
acceptor->async_accept (new_session->get_socket (), [this, new_session] (boost::system::error_code const & ec) {
|
||||
std::weak_ptr<nano::node> nano_weak = server.node.shared ();
|
||||
acceptor->async_accept (new_session->get_socket (), [this, new_session, nano_weak] (boost::system::error_code const & ec) {
|
||||
auto node = nano_weak.lock ();
|
||||
if (!node)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ec)
|
||||
{
|
||||
new_session->read_next_request ();
|
||||
}
|
||||
else
|
||||
{
|
||||
server.node.logger.always_log ("IPC: acceptor error: ", ec.message ());
|
||||
node->logger.always_log ("IPC: acceptor error: ", ec.message ());
|
||||
}
|
||||
|
||||
if (ec != boost::asio::error::operation_aborted && acceptor->is_open ())
|
||||
{
|
||||
this->accept ();
|
||||
accept ();
|
||||
}
|
||||
else
|
||||
{
|
||||
server.node.logger.always_log ("IPC: shutting down");
|
||||
node->logger.always_log ("IPC: shutting down");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue