Skip to content

Commit

Permalink
Merge branch 'develop' into hardening/own_lib_for_contextCache
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed May 11, 2021
2 parents 5d7d1c3 + 7863393 commit b4a9e13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/lib/alarmMgr/AlarmManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ AlarmManager::AlarmManager()
dbOk(true),
notificationErrorLogAlways(false),
badInputLogAlways(false),
dbErrorLogAlways(false)
dbErrorLogAlways(false),
stage(1)
{
}

Expand All @@ -78,8 +79,14 @@ int AlarmManager::init(bool logAlreadyRaisedAlarms)
notificationErrorLogAlways = logAlreadyRaisedAlarms;
badInputLogAlways = logAlreadyRaisedAlarms;
dbErrorLogAlways = logAlreadyRaisedAlarms;
stage = 2;

return semInit();
bool b = semInit();

if (b == true)
stage = 3;

return b;
}


Expand Down Expand Up @@ -193,6 +200,9 @@ void AlarmManager::dbErrorLogAlwaysSet(bool _dbErrorLogAlways)
*/
bool AlarmManager::dbError(const std::string& details)
{
if (stage < 3)
return false;

if (dbOk == false)
{
if (dbErrorLogAlways)
Expand Down
1 change: 1 addition & 0 deletions src/lib/alarmMgr/AlarmManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AlarmManager
bool badInputLogAlways;
bool dbErrorLogAlways;
sem_t sem;
int stage;

public:
AlarmManager();
Expand Down
15 changes: 9 additions & 6 deletions src/lib/mongoBackend/mongoConnectionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
* RECONNECT_RETRIES - number of retries after connect
* RECONNECT_DELAY - number of millisecs to sleep between retries
*/
#define RECONNECT_RETRIES 100
#define RECONNECT_DELAY 1000 // One second
#define RECONNECT_RETRIES 20
#define RECONNECT_DELAY 500 // milliseconds



Expand Down Expand Up @@ -147,7 +147,7 @@ static DBClientBase* mongoConnect

if (tryNo == 0)
{
LM_E(("Database Startup Error (cannot connect to mongo - doing %d retries with a %d microsecond interval)",
LM_E(("Database Startup Error (cannot connect to mongo - doing %d retries with a %d millisecond interval)",
retries,
RECONNECT_DELAY));
}
Expand All @@ -156,7 +156,7 @@ static DBClientBase* mongoConnect
LM_T(LmtMongo, ("Try %d connecting to mongo failed", tryNo));
}

usleep(RECONNECT_DELAY * 1000); // usleep accepts microseconds
usleep(RECONNECT_DELAY * 1000); // usleep accepts microseconds, RECONNECT_DELAY is in millis
}
}
else
Expand Down Expand Up @@ -190,7 +190,7 @@ static DBClientBase* mongoConnect

if (tryNo == 0)
{
LM_E(("Database Startup Error (cannot connect to mongo - doing %d retries with a %d microsecond interval)",
LM_E(("Database Startup Error (cannot connect to mongo - doing %d retries with a %d millisecond interval)",
retries,
RECONNECT_DELAY));
}
Expand All @@ -199,7 +199,7 @@ static DBClientBase* mongoConnect
LM_T(LmtMongo, ("Try %d connecting to mongo failed", tryNo));
}

usleep(RECONNECT_DELAY * 1000); // usleep accepts microseconds
usleep(RECONNECT_DELAY * 1000); // usleep accepts microseconds, RECONNECT_DELAY is in millis
}
}

Expand Down Expand Up @@ -329,6 +329,9 @@ int mongoConnectionPoolInit
connectionPool[ix].free = true;
connectionPool[ix].connection =
mongoConnect(host, db, rplSet, username, passwd, multitenant, writeConcern, timeout);

if ((connectionPool[ix].connection == NULL) && (ix == 0))
LM_X(1, ("Database Error (unable connect to mongo after a number of retries)"));
}

//
Expand Down

0 comments on commit b4a9e13

Please sign in to comment.