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
36 changes: 32 additions & 4 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ typedef struct __triggerConditionObj__
char referenceValue[MAX_LEN];
} triggerConditionObj ;

static bool isEmptySubscriberValue(const char *value)
{
if(value == NULL)
{
return true;
}
if(strlen(value) < 1 || value[0] == ' ' || strncmp(value, "NULL", 4) == 0)
{
return true;
}
return false;
}

static void freeRequestURIparam(void *data)
{
if(data != NULL)
Expand Down Expand Up @@ -1098,12 +1111,19 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo)
break;

case MTYPE_ACCUMULATE:
T2Debug("Marker type is ACCUMULATE Event Value : %s\n", eventInfo->value);
{
const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : "";
T2Debug("Marker type is ACCUMULATE Event Value : %s\n", safeValue);
if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue))
{
T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName);
break;
}
arraySize = Vector_Size(lookupEvent->u.accumulatedValues);
T2Debug("Current array size : %d \n", arraySize);
if( arraySize < MAX_ACCUMULATE)
{
Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(eventInfo->value));
Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(safeValue));
T2Debug("Sucessfully added value into vector New Size : %d\n", ++arraySize);
if(lookupEvent->reportTimestampParam == REPORTTIMESTAMP_UNIXEPOCH)
{
Expand Down Expand Up @@ -1137,16 +1157,24 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo)
T2Warning("Max size of the array has been reached Ignore New Value\n");
}
break;
}

case MTYPE_ABSOLUTE:
default:
{
const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : "";
if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue))
{
T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName);
break;
}
if(lookupEvent->u.markerValue)
{
free(lookupEvent->u.markerValue);
lookupEvent->u.markerValue = NULL;
}

lookupEvent->u.markerValue = strdup(eventInfo->value);
lookupEvent->u.markerValue = strdup(safeValue);
T2Debug("New marker value saved : %s\n", lookupEvent->u.markerValue);
if(lookupEvent->reportTimestampParam == REPORTTIMESTAMP_UNIXEPOCH)
{
Expand Down Expand Up @@ -1175,6 +1203,7 @@ T2ERROR Profile_storeMarkerEvent(const char *profileName, T2Event *eventInfo)
}
break;
}
}
pthread_mutex_unlock(&profile->eventMutex);
}
else
Expand Down Expand Up @@ -2121,4 +2150,3 @@ unsigned int getMinThresholdDuration(char *profileName)
return minThresholdDuration;
}


35 changes: 32 additions & 3 deletions source/bulkdata/profilexconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ static bool reportThreadExits = false;
static bool isAbortTriggered = false ;
static bool isOnDemandReport = false ;

static bool isEmptySubscriberValue(const char *value)
{
if(value == NULL)
{
return true;
}
if(strlen(value) < 1 || value[0] == ' ' || strncmp(value, "NULL", 4) == 0)
{
return true;
}
return false;
}

#ifdef GTEST_ENABLE
#define sendReportOverHTTP __wrap_sendReportOverHTTP
#define sendCachedReportsOverHTTP __wrap_sendCachedReportsOverHTTP
Expand Down Expand Up @@ -1112,12 +1125,19 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo)
break;

case MTYPE_XCONF_ACCUMULATE:
T2Debug("Marker type is ACCUMULATE Event Value : %s\n", eventInfo->value);
{
const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : "";
T2Debug("Marker type is ACCUMULATE Event Value : %s\n", safeValue);
if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue))
{
T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName);
break;
}
arraySize = Vector_Size(lookupEvent->u.accumulatedValues);
T2Debug("Current array size : %d \n", arraySize);
if( arraySize < MAX_ACCUMULATE)
{
Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(eventInfo->value));
Vector_PushBack(lookupEvent->u.accumulatedValues, strdup(safeValue));
T2Debug("Sucessfully added value into vector New Size : %d\n", ++arraySize);
}
else if ( arraySize == MAX_ACCUMULATE )
Expand All @@ -1131,17 +1151,26 @@ T2ERROR ProfileXConf_storeMarkerEvent(T2Event *eventInfo)
T2Warning("Max size of the array has been reached Ignore New Value\n");
}
break;
}

case MTYPE_XCONF_ABSOLUTE:
default:
{
const char *safeValue = (eventInfo->value != NULL) ? eventInfo->value : "";
if(!lookupEvent->reportEmptyParam && isEmptySubscriberValue(safeValue))
{
T2Debug("Skipping empty/null subscribe marker value for %s\n", lookupEvent->markerName);
break;
}
if(lookupEvent->u.markerValue)
{
free(lookupEvent->u.markerValue);
}
lookupEvent->u.markerValue = strdup(eventInfo->value);
lookupEvent->u.markerValue = strdup(safeValue);
T2Debug("New marker value saved : %s\n", lookupEvent->u.markerValue);
break;
}
}
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions source/reportgen/reportgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,13 @@ T2ERROR encodeEventMarkersInJSON(cJSON *valArray, Vector *eventMarkerList)
default:
if(eventMarker->u.markerValue != NULL)
{
if(!eventMarker->reportEmptyParam && checkForEmptyString(eventMarker->u.markerValue))
{
T2Debug("Skipping empty/\"NULL\" marker value for : %s\n", eventMarker->markerName);
free(eventMarker->u.markerValue);
eventMarker->u.markerValue = NULL;
break;
}
arrayItem = cJSON_CreateObject();
if(arrayItem == NULL)
{
Expand Down
Loading