Skip to content

Commit

Permalink
remove guarded by and new locking from argsmanager as it caused funct…
Browse files Browse the repository at this point in the history
…ional test failures
  • Loading branch information
Naviabheeman committed Aug 4, 2023
1 parent 20bf34e commit 4a6dc33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 5 additions & 8 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class ArgsManagerHelper {
* See also comments around ArgsManager::ArgsManager() below. */
static inline bool UseDefaultSection(const ArgsManager& am, const std::string& arg)
{
LOCK(am.cs_args);
return (am.m_network == TAPYRUS_MODES::PROD || am.m_network_only_args.count(arg) == 0);
}

Expand Down Expand Up @@ -336,7 +335,6 @@ void ArgsManager::WarnForSectionOnlyArgs()

// if it's okay to use the default section for this network, don't worry
if (m_network == TAPYRUS_MODES::PROD) return;
LOCK(cs_args);

for (const auto& arg : m_network_only_args) {
std::pair<bool, std::string> found_result;
Expand Down Expand Up @@ -427,7 +425,6 @@ bool ArgsManager::IsArgKnown(const std::string& key) const
} else {
arg_no_net = std::string("-") + key.substr(option_index + 1, std::string::npos);
}
LOCK(cs_args);

for (const auto& arg_map : m_available_args) {
if (arg_map.second.count(arg_no_net)) return true;
Expand Down Expand Up @@ -545,7 +542,6 @@ void ArgsManager::AddArg(const std::string& name, const std::string& help, const
if (eq_index == std::string::npos) {
eq_index = name.size();
}
LOCK(cs_args);
std::map<std::string, Arg>& arg_map = m_available_args[cat];
auto ret = arg_map.emplace(name.substr(0, eq_index), Arg(name.substr(eq_index, name.size() - eq_index), help, debug_only));
assert(ret.second); // Make sure an insertion actually happened
Expand All @@ -562,7 +558,6 @@ std::string ArgsManager::GetHelpMessage() const
{
const bool show_debug = gArgs.GetBoolArg("-help-debug", false);

LOCK(cs_args);
std::string usage = "";
for (const auto& arg_map : m_available_args) {
switch(arg_map.first) {
Expand Down Expand Up @@ -876,7 +871,6 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
}
// if there is an -includeconf in the override args, but it is empty, that means the user
// passed '-noincludeconf' on the command line, in which case we should not include anything
LOCK(cs_args);
if (m_override_args.count("-includeconf") == 0) {
std::string chain_id = TAPYRUS_MODES::GetChainName( GetChainMode());
std::vector<std::string> includeconf(GetArgs("-includeconf"));
Expand All @@ -889,8 +883,11 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)

// Remove -includeconf from configuration, so we can warn about recursion
// later
m_config_args.erase("-includeconf");
m_config_args.erase(std::string("-") + chain_id + ".includeconf");
{
LOCK(cs_args);
m_config_args.erase("-includeconf");
m_config_args.erase(std::string("-") + chain_id + ".includeconf");
}


for (const std::string& to_include : includeconf) {
Expand Down
8 changes: 4 additions & 4 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class ArgsManager
};

mutable RecursiveMutex cs_args;
std::map<std::string, std::vector<std::string>> m_override_args GUARDED_BY(cs_args);
std::map<std::string, std::vector<std::string>> m_config_args GUARDED_BY(cs_args);
std::map<std::string, std::vector<std::string>> m_override_args;
std::map<std::string, std::vector<std::string>> m_config_args;
std::string m_network;
std::set<std::string> m_network_only_args GUARDED_BY(cs_args);
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args GUARDED_BY(cs_args);
std::set<std::string> m_network_only_args;
std::map<OptionsCategory, std::map<std::string, Arg>> m_available_args;

bool ReadConfigStream(std::istream& stream, std::string& error, bool ignore_invalid_keys = false);

Expand Down

0 comments on commit 4a6dc33

Please sign in to comment.