diff --git a/procmgr/main.cpp b/procmgr/main.cpp index e2a5dd10e..aa11af949 100644 --- a/procmgr/main.cpp +++ b/procmgr/main.cpp @@ -47,6 +47,7 @@ using namespace threadpool; using namespace config; bool runStandby = false; +bool MsgThreadActive = false; bool runCold = false; string systemName = "system"; string iface_name; @@ -412,6 +413,8 @@ int main(int argc, char** argv) log.writeLog(__LINE__, "ERROR: makeConfig failed", LOG_TYPE_ERROR); } + + // This will never work..... try { oam.distributeConfigFile(); @@ -474,8 +477,6 @@ static void messageThread(Configuration config) sleep (1); } - log.writeLog(__LINE__, "Message Thread started ..", LOG_TYPE_DEBUG); - //read and cleanup port before trying to use try { @@ -489,6 +490,8 @@ static void messageThread(Configuration config) { } + log.writeLog(__LINE__, "Message Thread started ..", LOG_TYPE_DEBUG); + // //waiting for request // @@ -499,7 +502,7 @@ static void messageThread(Configuration config) try { MessageQueueServer procmgr("ProcMgr"); - + MsgThreadActive = true; for (;;) { try diff --git a/procmgr/processmanager.cpp b/procmgr/processmanager.cpp index 73bdd8d66..030d7b7ca 100644 --- a/procmgr/processmanager.cpp +++ b/procmgr/processmanager.cpp @@ -53,6 +53,7 @@ pthread_mutex_t THREAD_LOCK; extern string cloud; extern bool amazon; extern bool runStandby; +extern bool MsgThreadActive; extern string iface_name; extern string PMInstanceType; extern string UMInstanceType; @@ -9187,6 +9188,14 @@ int ProcessManager::switchParentOAMModule(std::string newActiveModuleName) //clear run standby flag; runStandby = false; + int retryCount = 0; + //sleep, give time for message thread to startup + while (!MsgThreadActive && retryCount < 5) + { + log.writeLog(__LINE__, "Waiting for Message Thread...", LOG_TYPE_DEBUG); + sleep(5); + ++retryCount; + } int moduleID = atoi(newActiveModuleName.substr(MAX_MODULE_TYPE_SIZE, MAX_MODULE_ID_SIZE).c_str()); @@ -9922,9 +9931,14 @@ int ProcessManager::OAMParentModuleChange() //clear run standby flag; runStandby = false; - + int retryCount = 0; //sleep, give time for message thread to startup - sleep(5); + while (!MsgThreadActive && retryCount < 5) + { + log.writeLog(__LINE__, "Waiting for Message Thread...", LOG_TYPE_DEBUG); + sleep(5); + ++retryCount; + } try {