From 2522a363c9a487f7c6e9f83f8b021ce3adfc481f Mon Sep 17 00:00:00 2001 From: Chalith Desaman Date: Mon, 8 Mar 2021 09:36:33 +0530 Subject: [PATCH] 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 --- src/conf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf.cpp b/src/conf.cpp index 77ef546d..73939e67 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -425,8 +425,8 @@ namespace conf cfg.mesh.max_connections = mesh["max_connections"].as(); cfg.mesh.max_known_connections = mesh["max_known_connections"].as(); cfg.mesh.max_in_connections_per_host = mesh["max_in_connections_per_host"].as(); - // 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;