Skip to content

Commit

Permalink
FIX broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Mar 7, 2024
1 parent 17740ee commit 5555108
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/mongoDriver/mongoConnectionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,20 @@ static int pingConnection(mongoc_client_t* conn, const char* db, bool mtenat)
// ping will be listDatabases in the admin DB. But if we run in not mtenant
// mode listCollections in the default database will suffice

std::string cmdString;
std::string effectiveDb;

bson_t* ping = bson_new();
if (mtenat)
{
cmd = "listDatabases";
cmdString = "listDatabases";
BSON_APPEND_INT32(ping, "listDatabases", 1);
BSON_APPEND_BOOL(ping, "nameOnly", true);
effectiveDb = "admin";
}
else
{
cmdString = "listCollections";
BSON_APPEND_INT32(ping, "listCollections", 1);
effectiveDb = db;
}
Expand All @@ -133,7 +135,7 @@ static int pingConnection(mongoc_client_t* conn, const char* db, bool mtenat)
int r = 0;
if (!mongoc_database_command_with_opts(database, ping, NULL, NULL, NULL, &error))
{
LM_T(LmtMongo, ("ping command (%s at db %s) falied: %s", cmd.c_str(), effectiveDb.c_str(), error.message));
LM_T(LmtMongo, ("ping command (%s at db %s) falied: %s", cmdString.c_str(), effectiveDb.c_str(), error.message));
// Reference error message: Authentication failed
// Reference error message: command listCollections requires authentication
if ((strstr(error.message, "Authentication failed") != NULL) || (strstr(error.message, "requires authentication") != NULL)) {
Expand Down

0 comments on commit 5555108

Please sign in to comment.