Comm session race conditions. (#192)

This commit is contained in:
Savinda Senevirathne
2020-12-11 16:36:04 +05:30
committed by GitHub
parent f2ed9040c0
commit 17313dae29
4 changed files with 9 additions and 9 deletions

View File

@@ -88,7 +88,7 @@ namespace comm
itr->check_last_activity_rules();
if (itr->state == SESSION_STATE::MUST_CLOSE)
itr->close(true);
itr->close();
if (itr->state == SESSION_STATE::CLOSED)
itr = sessions.erase(itr);
@@ -101,7 +101,7 @@ namespace comm
// Close and erase all sessions.
for (T &session : sessions)
session.close(false);
session.close();
sessions.clear();

View File

@@ -207,13 +207,13 @@ namespace comm
* Close the connection and wrap up any session processing threads.
* This will be only called by the global comm_server thread.
*/
void comm_session::close(const bool invoke_handler)
void comm_session::close()
{
if (state == SESSION_STATE::CLOSED)
return;
if (invoke_handler)
handle_close();
// Invoking the handler of the derived class for cleanups.
handle_close();
state = SESSION_STATE::CLOSED;
@@ -240,7 +240,7 @@ namespace comm
// Sessions use pubkey hex as unique id (skipping first 2 bytes key type prefix).
return uniqueid.substr(2, 10) + (is_inbound ? ":in" : ":out");
}
return uniqueid + (is_inbound ? ":in" : ":out");
}

View File

@@ -66,7 +66,7 @@ namespace comm
void process_outbound_msg_queue();
void check_last_activity_rules();
void mark_for_closure();
void close(const bool invoke_handler = true);
void close();
void mark_as_verified();
virtual const std::string display_name();

View File

@@ -855,12 +855,12 @@ namespace ledger
{
throw "Lcl file parsing error in file " + b + " in " + conf::ctx.hist_dir;
}
const std::string_view extension_a = util::fetch_file_extension(conf::ctx.hist_dir + a);
const std::string_view extension_a = util::fetch_file_extension(a);
if (extension_a != ".lcl")
{
throw "Found invalid file extension: " + std::string(extension_a) + " for lcl file " + a + " in " + conf::ctx.hist_dir;
}
const std::string_view extension_b = util::fetch_file_extension(conf::ctx.hist_dir + b);
const std::string_view extension_b = util::fetch_file_extension(b);
if (extension_b != ".lcl")
{
throw "Found invalid file extension: " + std::string(extension_b) + " for lcl file " + b + " in " + conf::ctx.hist_dir;