From 3a9d44a65211d400c1a416ca18256256e1f27a2a Mon Sep 17 00:00:00 2001 From: George Alexiou Date: Fri, 2 Feb 2024 17:09:50 +0000 Subject: [PATCH] Adjust timeout handling and fixing syntax error --- src/lib/mongoDriver/mongoConnectionPool.cpp | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/mongoDriver/mongoConnectionPool.cpp b/src/lib/mongoDriver/mongoConnectionPool.cpp index d086c0ffa6..64f5f94e5a 100644 --- a/src/lib/mongoDriver/mongoConnectionPool.cpp +++ b/src/lib/mongoDriver/mongoConnectionPool.cpp @@ -402,18 +402,20 @@ static std::string composeMongoUri // Check if timeout is not zero (which means it's either unset or explicitly set to a positive value) if (timeout != 0) { - // If timeout is negative (e.g., -1 indicating it's unset), set it to the default value of 10000 - if (timeout < 0) - { - timeout = 10000; - } - - char buf[STRING_SIZE_FOR_LONG]; + char buf[STRING_SIZE_FOR_LONG]; + // If timeout is negative (e.g., -1 indicating it's unset), set it to the default value of 10000 + if (timeout < 0) + { + i2s(10000, buf, sizeof(buf)); + } + else + { i2s(timeout, buf, sizeof(buf)); - uri += optionPrefix + "connectTimeoutMS=" + buf; - optionPrefix = "&"; + } + uri += optionPrefix + "connectTimeoutMS=" + buf; + optionPrefix = "&"; } - + } LM_T(LmtMongo, ("MongoDB connection URI: '%s'", offuscatePassword(uri, passwd).c_str())); return uri;