Changed the validation for max_connections and max_known_connections when reading the cfg (#262)

* Changed the validation for max_con and max_known_con when reading the config

* Minor comment fix

* Improved a code comment
This commit is contained in:
Chalith Desaman
2021-03-08 09:36:33 +05:30
committed by GitHub
parent 70a83893b0
commit 2522a363c9

View File

@@ -425,8 +425,8 @@ namespace conf
cfg.mesh.max_connections = mesh["max_connections"].as<uint16_t>();
cfg.mesh.max_known_connections = mesh["max_known_connections"].as<uint16_t>();
cfg.mesh.max_in_connections_per_host = mesh["max_in_connections_per_host"].as<uint16_t>();
// If max_connections is greater than max_known_connections then show error and stop execution.
if (cfg.mesh.max_known_connections > cfg.mesh.max_connections)
// If a value is specified for max_connections then max_known_connections value should not be 0(unlimited) and it should be less or equal than max_connections.
if (cfg.mesh.max_connections > 0 && (cfg.mesh.max_known_connections > cfg.mesh.max_connections || cfg.mesh.max_known_connections == 0))
{
std::cerr << "Invalid configuration values: mesh max_known_connections count should not exceed mesh max_connections." << '\n';
return -1;