diff --git a/source/bulkdata/profilexconf.c b/source/bulkdata/profilexconf.c index 9840b4dd..08d35f00 100644 --- a/source/bulkdata/profilexconf.c +++ b/source/bulkdata/profilexconf.c @@ -220,6 +220,11 @@ static void* CollectAndReportXconf(void* data) do { T2Info("%s while Loop -- START \n", __FUNCTION__); + if(singleProfile == NULL) + { + T2Error("%s is called with empty profile, profile reload might be in-progress, skip the request\n", __FUNCTION__); + goto reportXconfThreadEnd; + } profile = singleProfile; Vector *profileParamVals = NULL; Vector *grepResultList = NULL; @@ -498,7 +503,6 @@ static void* CollectAndReportXconf(void* data) //pthread_mutex_unlock(&plMutex); reportXconfThreadEnd : T2Info("%s while Loop -- END \n", __FUNCTION__); - T2Info("%s --out\n", __FUNCTION__); pthread_cond_wait(&reuseThread, &plMutex); } while(initialized); @@ -596,7 +600,6 @@ T2ERROR ProfileXConf_uninit() pthread_cond_signal(&reuseThread); pthread_mutex_unlock(&plMutex); pthread_join(singleProfile->reportThread, NULL); - reportThreadExits = false; singleProfile->reportInProgress = false ; T2Info("Final report is completed, releasing profile memory\n"); } @@ -731,21 +734,13 @@ T2ERROR ProfileXConf_delete(ProfileXConf *profile) if(singleProfile->reportInProgress) { - T2Info("Waiting for CollectAndReport to be complete : %s\n", singleProfile->name); - pthread_mutex_lock(&plMutex); - initialized = false; - T2Info("Sending signal to reuse Thread in CollectAndReportXconf\n"); - pthread_cond_signal(&reuseThread); - pthread_mutex_unlock(&plMutex); - pthread_join(singleProfile->reportThread, NULL); - T2Info("reportThread exits and initialising the profile list\n"); - reportThreadExits = false; - initialized = true; - singleProfile->reportInProgress = false ; + T2Info("Waiting for CollectAndReportXconf to be complete : %s\n", singleProfile->name); } pthread_mutex_lock(&plMutex); + profile->reportThread = singleProfile->reportThread; + size_t count = Vector_Size(singleProfile->cachedReportList); // Copy any cached message present in previous single profile to new profile if(isNameEqual) @@ -1013,9 +1008,14 @@ T2ERROR ProfileXConf_terminateReport() T2ERROR ret = T2ERROR_FAILURE; + pthread_mutex_lock(&plMutex); + if(!singleProfile) { T2Error("Xconf profile is not set.\n"); + + pthread_mutex_unlock(&plMutex); + return ret; } @@ -1043,6 +1043,8 @@ T2ERROR ProfileXConf_terminateReport() T2Info("No report generation in progress. No further action required for abort.\n"); } + pthread_mutex_unlock(&plMutex); + return ret; }