Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "dcautil.h"
#include "t2parser.h"
#include "rbusInterface.h"
#include "legacyutils.h"

#if defined(PRIVACYMODES_CONTROL)
#include "rdkservices_privacyutils.h"
Expand Down Expand Up @@ -172,6 +173,10 @@ static void freeProfile(void *data)
{
Vector_Destroy(profile->gMarkerList, freeGMarker);
}
if(profile->topMarkerList)
{
Vector_Destroy(profile->topMarkerList, freeGMarker);
}
if(profile->paramList)
{
Vector_Destroy(profile->paramList, freeParam);
Expand Down Expand Up @@ -322,6 +327,7 @@ static void* CollectAndReport(void* data)
pthread_cond_init(&profile->reuseThread, NULL);
pthread_mutex_lock(&profile->reuseThreadMutex);
profile->threadExists = true;
//GrepSeekProfile *GPF = profile->GrepSeekProfle;
do
{
T2Info("%s while Loop -- START \n", __FUNCTION__);
Expand All @@ -330,6 +336,8 @@ static void* CollectAndReport(void* data)
pthread_cond_signal(&profile->reportInProgressCond);
pthread_mutex_unlock(&profile->reportInProgressMutex);

int count = profile->grepSeekProfile->execCounter;

Vector *profileParamVals = NULL;
Vector *grepResultList = NULL;
cJSON *valArray = NULL;
Expand All @@ -344,6 +352,7 @@ static void* CollectAndReport(void* data)
char* customLogPath = NULL;



T2ERROR ret = T2ERROR_FAILURE;
if( profile->name == NULL || profile->encodingType == NULL || profile->protocol == NULL )
{
Expand Down Expand Up @@ -434,16 +443,33 @@ static void* CollectAndReport(void* data)
if(profile->paramList != NULL && Vector_Size(profile->paramList) > 0)
{
T2Debug("Fetching TR-181 Object/Parameter Values\n");
profileParamVals = getProfileParameterValues(profile->paramList);
profileParamVals = getProfileParameterValues(profile->paramList, count);
if(profileParamVals != NULL)
{
encodeParamResultInJSON(valArray, profile->paramList, profileParamVals);
}
Vector_Destroy(profileParamVals, freeProfileValues);
}
if(profile->topMarkerList != NULL && Vector_Size(profile->topMarkerList) > 0)
{
Vector *topMarkerResultList = NULL;
Vector_Create(&topMarkerResultList);
processTopPattern(profile->name, profile->topMarkerList, topMarkerResultList, 0);
long int reportSize = Vector_Size(topMarkerResultList);
if(reportSize != 0)
{
T2Info("Top markers report is compleated report size %ld\n", (unsigned long)reportSize);
encodeGrepResultInJSON(valArray, topMarkerResultList);
}
else
{
T2Debug("Top markers report generated but is empty possabliy the memory value is changed");
}
Vector_Destroy(topMarkerResultList, freeGResult);
}
if(profile->gMarkerList != NULL && Vector_Size(profile->gMarkerList) > 0)
{
getGrepResults(profile->name, profile->gMarkerList, &grepResultList, profile->bClearSeekMap, false, customLogPath); // Passing 5th argument as false so that it doesn't check rotated logs for the first reporting after bootup for multiprofiles.
getGrepResults(&(profile->grepSeekProfile), profile->gMarkerList, &grepResultList, profile->bClearSeekMap, false, customLogPath); // Passing 5th argument as false so that it doesn't check rotated logs for the first reporting after bootup for multiprofiles.
encodeGrepResultInJSON(valArray, grepResultList);
Vector_Destroy(grepResultList, freeGResult);
}
Expand Down Expand Up @@ -484,7 +510,7 @@ static void* CollectAndReport(void* data)
#ifdef PERSIST_LOG_MON_REF
if(profile->saveSeekConfig)
{
saveSeekConfigtoFile(profile->name);
saveSeekConfigtoFile(profile->name, profile->grepSeekProfile);
}
if(profile->checkPreviousSeek)
{
Expand Down Expand Up @@ -1168,9 +1194,9 @@ T2ERROR deleteAllProfiles(bool delFromDisk)
pthread_join(tempProfile->reportThread, NULL);
tempProfile->threadExists = false;
}
if (Vector_Size(tempProfile->gMarkerList) > 0)
if(tempProfile->grepSeekProfile)
{
removeGrepConfig(tempProfile->name, true, true);
freeGrepSeekProfile(tempProfile->grepSeekProfile);
}
pthread_mutex_unlock(&plMutex);
if(delFromDisk == true)
Expand Down Expand Up @@ -1273,9 +1299,9 @@ T2ERROR deleteProfile(const char *profileName)
rbusT2ConsumerUnReg(profile->triggerConditionList);
}

if (Vector_Size(profile->gMarkerList) > 0)
if(profile->grepSeekProfile)
{
removeGrepConfig((char*)profileName, true, true);
freeGrepSeekProfile(profile->grepSeekProfile);
}

pthread_mutex_destroy(&profile->reportInProgressMutex);
Expand Down Expand Up @@ -1392,7 +1418,7 @@ static void loadReportProfilesFromDisk(bool checkPreviousSeek)
if(T2ERROR_SUCCESS == addProfile(profile))
{
#ifdef PERSIST_LOG_MON_REF
if(checkPreviousSeek && profile->generateNow == false && profile->triggerConditionList == NULL && loadSavedSeekConfig(profile->name) == T2ERROR_SUCCESS && firstBootStatus() )
if(checkPreviousSeek && profile->generateNow == false && profile->triggerConditionList == NULL && profile->grepSeekProfile && loadSavedSeekConfig(profile->name, profile->grepSeekProfile) == T2ERROR_SUCCESS && firstBootStatus() )
{
profile->checkPreviousSeek = true;
}
Expand Down
3 changes: 3 additions & 0 deletions source/bulkdata/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "t2common.h"
#include "vector.h"
#include "reportgen.h"
#include "legacyutils.h"

typedef struct _JSONEncoding
{
Expand Down Expand Up @@ -77,6 +78,7 @@ typedef struct _Profile
T2RBUS *t2RBUSDest;
Vector *eMarkerList;
Vector *gMarkerList;
Vector *topMarkerList;
Vector *cachedReportList;
cJSON *jsonReportObj;
pthread_t reportThread;
Expand All @@ -90,6 +92,7 @@ typedef struct _Profile
pthread_cond_t reuseThread;
pthread_mutex_t reuseThreadMutex;
bool threadExists;
GrepSeekProfile *grepSeekProfile; // To store GrepConfig
} Profile;

T2ERROR initProfileList(bool checkPreviousSeek);
Expand Down
57 changes: 46 additions & 11 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "vector.h"
#include "dcautil.h"
#include "t2parserxconf.h"
#include "legacyutils.h"

#define T2REPORT_HEADER "T2"
#define T2REPORT_HEADERVAL "1.0"
Expand Down Expand Up @@ -119,6 +120,10 @@ static void freeProfileXConf()
{
Vector_Destroy(singleProfile->gMarkerList, freeGMarker);
}
if(singleProfile->topMarkerList)
{
Vector_Destroy(singleProfile->topMarkerList, freeGMarker);
}
if(singleProfile->paramList)
{
Vector_Destroy(singleProfile->paramList, freeParam);
Expand All @@ -136,6 +141,10 @@ static void freeProfileXConf()
free(singleProfile->cachedReportList);
singleProfile->cachedReportList = NULL;
}
if(singleProfile->grepSeekProfile)
{
freeGrepSeekProfile(singleProfile->grepSeekProfile);
}
free(singleProfile);
singleProfile = NULL;
}
Expand Down Expand Up @@ -202,6 +211,7 @@ static void* CollectAndReportXconf(void* data)
}
pthread_cond_init(&reuseThread, NULL);
reportThreadExits = true;
//GrepSeekProfile *GPF = profile->grepSeekProfile;
do
{
T2Info("%s while Loop -- START \n", __FUNCTION__);
Expand All @@ -213,10 +223,15 @@ static void* CollectAndReportXconf(void* data)
char* customLogPath = NULL;
bool checkRotated = true;

int count = profile->grepSeekProfile->execCounter;
T2Debug("CollectAndReportXconf count = %d\n", count);

struct timespec startTime;
struct timespec endTime;
struct timespec elapsedTime;



T2ERROR ret = T2ERROR_FAILURE;
if(profile->name != NULL)
{
Expand Down Expand Up @@ -252,17 +267,34 @@ static void* CollectAndReportXconf(void* data)

if(profile->paramList != NULL && Vector_Size(profile->paramList) > 0)
{
profileParamVals = getProfileParameterValues(profile->paramList);
profileParamVals = getProfileParameterValues(profile->paramList, count);
T2Info("Fetch complete for TR-181 Object/Parameter Values for parameters \n");
if(profileParamVals != NULL)
{
encodeParamResultInJSON(valArray, profile->paramList, profileParamVals);
}
Vector_Destroy(profileParamVals, freeProfileValues);
}
if(profile->topMarkerList != NULL && Vector_Size(profile->topMarkerList) > 0)
{
Vector *topMarkerResultList = NULL;
Vector_Create(&topMarkerResultList);
processTopPattern(profile->name, profile->topMarkerList, topMarkerResultList, count);
long int reportSize = Vector_Size(topMarkerResultList);
if(reportSize != 0)
{
T2Info("Top markers report is compleated report size %ld\n", (unsigned long)reportSize);
encodeGrepResultInJSON(valArray, topMarkerResultList);
}
else
{
T2Debug("Top markers report generated but is empty possabliy the memory value is changed");
}
Vector_Destroy(topMarkerResultList, freeGResult);
}
if(profile->gMarkerList != NULL && Vector_Size(profile->gMarkerList) > 0)
{
getGrepResults(profile->name, profile->gMarkerList, &grepResultList, profile->bClearSeekMap, checkRotated, customLogPath); // Passing 5th argument as true to check rotated logs only in case of single profile
getGrepResults(&(profile->grepSeekProfile), profile->gMarkerList, &grepResultList, profile->bClearSeekMap, checkRotated, customLogPath); // Passing 5th argument as true to check rotated logs only in case of single profile
T2Info("Grep complete for %lu markers \n", (unsigned long)Vector_Size(profile->gMarkerList));
encodeGrepResultInJSON(valArray, grepResultList);
Vector_Destroy(grepResultList, freeGResult);
Expand All @@ -277,7 +309,8 @@ static void* CollectAndReportXconf(void* data)
ret = prepareJSONReport(profile->jsonReportObj, &jsonReport);
destroyJSONReport(profile->jsonReportObj);
profile->jsonReportObj = NULL;

clock_gettime(CLOCK_REALTIME, &endTime);
T2Info("Processing time for profile %s is %ld seconds\n", profile->name, (long)(endTime.tv_sec - startTime.tv_sec));
if(ret != T2ERROR_SUCCESS)
{
T2Error("Unable to generate report for : %s\n", profile->name);
Expand Down Expand Up @@ -348,7 +381,7 @@ static void* CollectAndReportXconf(void* data)
#ifdef PERSIST_LOG_MON_REF
if(profile->saveSeekConfig)
{
saveSeekConfigtoFile(profile->name);
saveSeekConfigtoFile(profile->name, profile->grepSeekProfile);
}
if(profile->checkPreviousSeek)
{
Expand Down Expand Up @@ -405,7 +438,7 @@ static void* CollectAndReportXconf(void* data)
}

# ifdef PERSIST_LOG_MON_REF
if(T2ERROR_SUCCESS == saveSeekConfigtoFile(profile->name))
if(T2ERROR_SUCCESS == saveSeekConfigtoFile(profile->name, profile->grepSeekProfile))
{
T2Info("Successfully saved grep config to file for profile: %s\n", profile->name);
}
Expand Down Expand Up @@ -497,7 +530,7 @@ T2ERROR ProfileXConf_init(bool checkPreviousSeek)
if(T2ERROR_SUCCESS == processConfigurationXConf(config->configData, &profile))
{
#ifdef PERSIST_LOG_MON_REF
if(checkPreviousSeek && loadSavedSeekConfig(profile->name) == T2ERROR_SUCCESS && firstBootStatus())
if(checkPreviousSeek && profile->grepSeekProfile && loadSavedSeekConfig(profile->name, profile->grepSeekProfile) == T2ERROR_SUCCESS && firstBootStatus())
{
profile->checkPreviousSeek = true;
}
Expand Down Expand Up @@ -640,8 +673,9 @@ bool ProfileXConf_isNameEqual(char* profileName)
{
if(singleProfile && (singleProfile->name != NULL) && (profileName != NULL) && !strcmp(singleProfile->name, profileName)) //Adding NULL check to avoid strcmp crash
{
T2Info("singleProfile->name = %s and profileName = %s\n", singleProfile->name, profileName);
isName = true;
T2Info("singleProfile->name = %s and profileName = %s and return %s\n", singleProfile->name, profileName, isName ? "true" : "false");

}
}
pthread_mutex_unlock(&plMutex);
Expand All @@ -656,7 +690,7 @@ T2ERROR ProfileXConf_delete(ProfileXConf *profile)
T2Error("profile list is not initialized yet, ignoring\n");
return T2ERROR_FAILURE;
}

T2Debug("calling ProfileXConf_isNameEqual function form %s and line %d\n", __FUNCTION__, __LINE__);
bool isNameEqual = ProfileXConf_isNameEqual(profile->name);

pthread_mutex_lock(&plMutex);
Expand Down Expand Up @@ -787,18 +821,19 @@ T2ERROR ProfileXConf_delete(ProfileXConf *profile)

if (Vector_Size(singleProfile->gMarkerList) > 0 )
{
bool clearSeekMap = true;
if(isNameEqual)
{
clearSeekMap = false;
freeGrepSeekProfile(profile->grepSeekProfile);
profile->grepSeekProfile = singleProfile->grepSeekProfile;
profile->grepSeekProfile->execCounter = 0;
singleProfile->grepSeekProfile = NULL;
}
#ifdef PERSIST_LOG_MON_REF
else
{
removeProfileFromDisk(SEEKFOLDER, singleProfile->name);
}
#endif
removeGrepConfig(singleProfile->name, clearSeekMap, true);
}


Expand Down
4 changes: 4 additions & 0 deletions source/bulkdata/profilexconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "t2eventreceiver.h"
#include "vector.h"
#include "reportgen.h"
#include "t2collection.h"
#include "legacyutils.h"

typedef enum
{
Expand Down Expand Up @@ -61,9 +63,11 @@ typedef struct _ProfileXConf
T2HTTP *t2HTTPDest;
Vector *eMarkerList;
Vector *gMarkerList;
Vector *topMarkerList;
Vector *cachedReportList;
cJSON *jsonReportObj;
pthread_t reportThread;
GrepSeekProfile *grepSeekProfile; // To store GrepConfig
} ProfileXConf;

T2ERROR ProfileXConf_init(bool checkPreviousSeek);
Expand Down
10 changes: 9 additions & 1 deletion source/bulkdata/reportprofiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void ReportProfiles_TimeoutCb(char* profileName, bool isClearSeekMap)
{
T2Info("%s ++in\n", __FUNCTION__);

T2Info("calling ProfileXConf_isNameEqual function form %s and line %d\n", __FUNCTION__, __LINE__);
if(ProfileXConf_isNameEqual(profileName))
{
T2Debug("isclearSeekmap = %s \n", isClearSeekMap ? "true" : "false");
Expand All @@ -238,6 +239,8 @@ void ReportProfiles_ActivationTimeoutCb(char* profileName)
T2Info("%s ++in\n", __FUNCTION__);

bool isDeleteRequired = false;
T2Debug("calling ProfileXConf_isNameEqual function form %s and line %d\n", __FUNCTION__, __LINE__);

if(ProfileXConf_isNameEqual(profileName))
{
T2Error("ActivationTimeout received for Xconf profile. Ignoring!!!! \n");
Expand Down Expand Up @@ -281,6 +284,7 @@ void ReportProfiles_ActivationTimeoutCb(char* profileName)
T2ERROR ReportProfiles_storeMarkerEvent(char *profileName, T2Event *eventInfo)
{
T2Debug("%s ++in\n", __FUNCTION__);
T2Debug("calling ProfileXConf_isNameEqual function form %s and line %d\n", __FUNCTION__, __LINE__);

if(ProfileXConf_isNameEqual(profileName))
{
Expand Down Expand Up @@ -636,6 +640,10 @@ T2ERROR initReportProfiles()

}

//Initialise the properties file RDK-58222
T2InitProperties();
T2Info("InitProperties is successful\n");

// This indicates telemetry has started
FILE* bootFlag = NULL ;
bootFlag = fopen(BOOTFLAG, "w+");
Expand Down Expand Up @@ -1380,7 +1388,7 @@ int __ReportProfiles_ProcessReportProfilesMsgPackBlob(void *msgpack, bool checkP
{
ReportProfiles_addReportProfile(profile);
#ifdef PERSIST_LOG_MON_REF
if(checkPreviousSeek && profile->generateNow == false && profile->triggerConditionList == NULL && loadSavedSeekConfig(profile->name) == T2ERROR_SUCCESS && firstBootStatus() )
if(checkPreviousSeek && profile->generateNow == false && profile->triggerConditionList == NULL && profile->grepSeekProfile && loadSavedSeekConfig(profile->name, profile->grepSeekProfile) == T2ERROR_SUCCESS && firstBootStatus() )
{
T2Info("Previous seek is enabled for profile %s \n", profile->name);
profile->checkPreviousSeek = true;
Expand Down
Loading