Removing null checks for nano::bootstrap::socket since it's required to be non-null on construction and is never nulled out during execution. (#3441)

This commit is contained in:
clemahieu 2021-09-09 09:15:59 +01:00 committed by GitHub
commit 2e769bf5b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 21 deletions

View file

@ -136,10 +136,7 @@ void nano::bootstrap_server::stop ()
{ {
if (!stopped.exchange (true)) if (!stopped.exchange (true))
{ {
if (socket != nullptr) socket->close ();
{
socket->close ();
}
} }
} }
@ -583,25 +580,17 @@ void nano::bootstrap_server::finish_request_async ()
void nano::bootstrap_server::timeout () void nano::bootstrap_server::timeout ()
{ {
if (socket != nullptr) if (socket->has_timed_out ())
{ {
if (socket->has_timed_out ()) if (node->config.logging.bulk_pull_logging ())
{ {
if (node->config.logging.bulk_pull_logging ()) node->logger.try_log ("Closing incoming tcp / bootstrap server by timeout");
{
node->logger.try_log ("Closing incoming tcp / bootstrap server by timeout");
}
{
nano::lock_guard<nano::mutex> lock (node->bootstrap.mutex);
node->bootstrap.connections.erase (this);
}
socket->close ();
} }
} {
else nano::lock_guard<nano::mutex> lock (node->bootstrap.mutex);
{ node->bootstrap.connections.erase (this);
nano::lock_guard<nano::mutex> lock (node->bootstrap.mutex); }
node->bootstrap.connections.erase (this); socket->close ();
} }
} }

View file

@ -59,7 +59,7 @@ public:
bool is_bootstrap_connection (); bool is_bootstrap_connection ();
bool is_realtime_connection (); bool is_realtime_connection ();
std::shared_ptr<std::vector<uint8_t>> receive_buffer; std::shared_ptr<std::vector<uint8_t>> receive_buffer;
std::shared_ptr<nano::socket> socket; std::shared_ptr<nano::socket> const socket;
std::shared_ptr<nano::node> node; std::shared_ptr<nano::node> node;
nano::mutex mutex; nano::mutex mutex;
std::queue<std::unique_ptr<nano::message>> requests; std::queue<std::unique_ptr<nano::message>> requests;