From b19c78a495289c2270e442e4b066eec3959c2937 Mon Sep 17 00:00:00 2001 From: Yogeswaran K <166126056+yogeswaransky@users.noreply.github.com> Date: Thu, 25 Jun 2026 00:17:37 +0530 Subject: [PATCH 1/7] Move mutex and message bus initialization into t2_init --- source/commonlib/telemetry_busmessage_sender.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/commonlib/telemetry_busmessage_sender.c b/source/commonlib/telemetry_busmessage_sender.c index eb77e5c8..ad556502 100644 --- a/source/commonlib/telemetry_busmessage_sender.c +++ b/source/commonlib/telemetry_busmessage_sender.c @@ -757,6 +757,16 @@ static int report_or_cache_data(char* telemetry_data, const char* markerName) void t2_init(char *component) { componentName = strdup(component); + initMutex(); + + if(initMessageBus() != T2ERROR_SUCCESS) + { + EVENT_ERROR("%s:%d, T2:initMessageBus failed in t2_init, will retry during event send\n", __func__, __LINE__); + } + else + { + isRFCT2Enable = true; + } } void t2_uninit(void) @@ -787,7 +797,6 @@ T2ERROR t2_event_s(const char* marker, const char* value) EVENT_DEBUG("%s:%d, T2:component with pid = %d is trying to send event %s with value %s without component name \n", __func__, __LINE__, (int) getpid(), marker, value); return T2ERROR_COMPONENT_NULL; } - initMutex(); pthread_mutex_lock(&sMutex); if ( NULL == marker || NULL == value) { From abbe305bb3b058418dcd095a6ff96255fb261341 Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Fri, 26 Jun 2026 07:59:37 +0000 Subject: [PATCH 2/7] RDKEMW-19134: Move mutex and message bus initialization into t2_init Signed-off-by: Yogeswaran K --- source/commonlib/telemetry_busmessage_sender.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/commonlib/telemetry_busmessage_sender.c b/source/commonlib/telemetry_busmessage_sender.c index ad556502..5027777b 100644 --- a/source/commonlib/telemetry_busmessage_sender.c +++ b/source/commonlib/telemetry_busmessage_sender.c @@ -204,7 +204,7 @@ static void rBusInterface_Uninit( ) static T2ERROR initMessageBus( ) { - // EVENT_DEBUG("%s ++in\n", __FUNCTION__); + EVENT_ERROR("%s ++in\n", __FUNCTION__); T2ERROR status = T2ERROR_SUCCESS; char* component_id = (char*)CCSP_FIXED_COMP_ID; #if defined(CCSP_SUPPORT_ENABLED) @@ -248,7 +248,7 @@ static T2ERROR initMessageBus( ) } } #endif // CCSP_SUPPORT_ENABLED - // EVENT_DEBUG("%s --out\n", __FUNCTION__); + EVENT_ERROR("%s --out\n", __FUNCTION__); return status; } @@ -440,6 +440,7 @@ int filtered_event_send(const char* data, const char *markerName) rbusError_t ret = RBUS_ERROR_SUCCESS; int status = 0 ; EVENT_DEBUG("%s ++in\n", __FUNCTION__); + EVENT_ERROR("%s ++in\n", __FUNCTION__); if(!bus_handle) { EVENT_ERROR("bus_handle is null .. exiting !!! \n"); @@ -530,6 +531,7 @@ int filtered_event_send(const char* data, const char *markerName) } #endif // CCSP_SUPPORT_ENABLED EVENT_DEBUG("%s --out with status %d \n", __FUNCTION__, status); + EVENT_ERROR("%s --out with status %d \n", __FUNCTION__, status); return status; } @@ -560,6 +562,7 @@ static T2ERROR doPopulateEventMarkerList( ) snprintf(deNameSpace[0], 124, "%s%s%s", T2_ROOT_PARAMETER, componentName, T2_EVENT_LIST_PARAM_SUFFIX); EVENT_DEBUG("rbus mode : Query marker list with data element = %s \n", deNameSpace[0]); + EVENT_ERROR("rbus mode : Query marker list with data element = %s \n", deNameSpace[0]); pthread_mutex_lock(&markerListMutex); EVENT_DEBUG("Lock markerListMutex & Clean up eventMarkerMap \n"); @@ -596,6 +599,7 @@ static T2ERROR doPopulateEventMarkerList( ) eventMarkerMap = hash_map_create(); rbusProperty_t rbusPropertyList = rbusObject_GetProperties(objectValue); EVENT_DEBUG("\t rbus mode : Update event map for component %s with below events : \n", componentName); + EVENT_ERROR("\t rbus mode : Update event map for component %s with below events : \n", componentName); while(NULL != rbusPropertyList) { const char* eventname = rbusProperty_GetName(rbusPropertyList); @@ -668,6 +672,7 @@ static bool isCachingRequired( ) rbusError_t retVal = RBUS_ERROR_SUCCESS; retVal = rbus_getUint(bus_handle, T2_OPERATIONAL_STATUS, &t2ReadyStatus); + EVENT_ERROR("Retrieved T2 Operational status: %d\n", t2ReadyStatus); if(retVal != RBUS_ERROR_SUCCESS) { @@ -741,7 +746,7 @@ static int report_or_cache_data(char* telemetry_data, const char* markerName) if(isT2Ready) { - // EVENT_DEBUG("T2: Sending event : %s\n", telemetry_data); + EVENT_ERROR("T2: Sending event : %s\n", telemetry_data); ret = filtered_event_send(telemetry_data, markerName); if(0 != ret) { From 8601cdcd74096912f56bf061021db09a65e6ca3e Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Fri, 26 Jun 2026 10:34:10 +0000 Subject: [PATCH 3/7] RDKB-65318: Enhancements Signed-off-by: Yogeswaran K --- source/commonlib/telemetry_busmessage_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/commonlib/telemetry_busmessage_internal.h b/source/commonlib/telemetry_busmessage_internal.h index f34ce0c8..403c4ef6 100644 --- a/source/commonlib/telemetry_busmessage_internal.h +++ b/source/commonlib/telemetry_busmessage_internal.h @@ -27,7 +27,7 @@ const char destCompPath[64] = "/com/cisco/spvtg/ccsp/pam"; #define EVENT_ERROR(format, ...) \ - fprintf(stderr, "T2ERROR:%s %s:%d: ", __func__ , __FILE__, __LINE__ ); \ + fprintf(stderr, "T2INFO:%s %s:%d: ", __func__ , __FILE__, __LINE__ ); \ fprintf(stderr, (format), ##__VA_ARGS__ ); \ fprintf(stderr, "\n" ); From 4ded52c5087e34f4d6bb2042404c872aaf228ec6 Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Fri, 26 Jun 2026 10:34:10 +0000 Subject: [PATCH 4/7] RDKEMW-19134: Move mutex and message bus initialization into t2_init Signed-off-by: Yogeswaran K --- source/commonlib/telemetry_busmessage_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/commonlib/telemetry_busmessage_internal.h b/source/commonlib/telemetry_busmessage_internal.h index f34ce0c8..403c4ef6 100644 --- a/source/commonlib/telemetry_busmessage_internal.h +++ b/source/commonlib/telemetry_busmessage_internal.h @@ -27,7 +27,7 @@ const char destCompPath[64] = "/com/cisco/spvtg/ccsp/pam"; #define EVENT_ERROR(format, ...) \ - fprintf(stderr, "T2ERROR:%s %s:%d: ", __func__ , __FILE__, __LINE__ ); \ + fprintf(stderr, "T2INFO:%s %s:%d: ", __func__ , __FILE__, __LINE__ ); \ fprintf(stderr, (format), ##__VA_ARGS__ ); \ fprintf(stderr, "\n" ); From 76a633f044ee5316727c07393257844836121799 Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Sun, 5 Jul 2026 14:58:33 +0000 Subject: [PATCH 5/7] RDKEMW-19134: Synchronizing t2_init with t2_event calls Signed-off-by: Yogeswaran K --- .../commonlib/telemetry_busmessage_sender.c | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/source/commonlib/telemetry_busmessage_sender.c b/source/commonlib/telemetry_busmessage_sender.c index 5027777b..5dcfe0f7 100644 --- a/source/commonlib/telemetry_busmessage_sender.c +++ b/source/commonlib/telemetry_busmessage_sender.c @@ -57,6 +57,7 @@ static bool isT2Ready = false; static bool isRbusEnabled = false ; static pthread_mutex_t initMtx = PTHREAD_MUTEX_INITIALIZER; static bool isMutexInitialized = false ; +static volatile bool isT2InitComplete = false ; static hash_map_t *eventMarkerMap = NULL; @@ -756,12 +757,11 @@ static int report_or_cache_data(char* telemetry_data, const char* markerName) return ret; } -/** - * Initialize the component name with unique name - */ -void t2_init(char *component) +static void *t2_init_worker(void *arg) { - componentName = strdup(component); + (void)arg; + pthread_detach(pthread_self()); + initMutex(); if(initMessageBus() != T2ERROR_SUCCESS) @@ -772,6 +772,24 @@ void t2_init(char *component) { isRFCT2Enable = true; } + + isT2InitComplete = true; + return NULL; +} + +/** + * Initialize the component name with unique name + */ +void t2_init(char *component) +{ + pthread_t initThread; + componentName = strdup(component); + + if(pthread_create(&initThread, NULL, t2_init_worker, NULL) != 0) + { + EVENT_ERROR("%s:%d, T2:Failed to create init worker thread, falling back to sync init\n", __func__, __LINE__); + t2_init_worker(NULL); + } } void t2_uninit(void) @@ -797,6 +815,11 @@ T2ERROR t2_event_s(const char* marker, const char* value) T2ERROR retStatus = T2ERROR_FAILURE ; EVENT_DEBUG("%s ++in\n", __FUNCTION__); char* strvalue = NULL; + if(!isT2InitComplete) + { + EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + return T2ERROR_FAILURE; + } if(componentName == NULL) { EVENT_DEBUG("%s:%d, T2:component with pid = %d is trying to send event %s with value %s without component name \n", __func__, __LINE__, (int) getpid(), marker, value); @@ -844,6 +867,11 @@ T2ERROR t2_event_f(const char* marker, double value) T2ERROR retStatus = T2ERROR_FAILURE ; EVENT_DEBUG("%s ++in\n", __FUNCTION__); + if(!isT2InitComplete) + { + EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + return T2ERROR_FAILURE; + } if(componentName == NULL) { EVENT_DEBUG("%s:%d, T2:component with pid = %d is trying to send event %s with value %lf without component name \n", __func__, __LINE__, (int) getpid(), marker, value); @@ -888,6 +916,11 @@ T2ERROR t2_event_d(const char* marker, int value) T2ERROR retStatus = T2ERROR_FAILURE ; EVENT_DEBUG("%s ++in\n", __FUNCTION__); + if(!isT2InitComplete) + { + EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + return T2ERROR_FAILURE; + } if(componentName == NULL) { EVENT_DEBUG("%s:%d, T2:component with pid = %d is trying to send event %s with value %d without component name \n", __func__, __LINE__, (int) getpid(), marker, value); From b08e01ddda56b174f0557aabd083f3e01e12f7cc Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Mon, 6 Jul 2026 09:51:58 +0000 Subject: [PATCH 6/7] RDKEMW-19134: Synchronizing t2_init with t2_event calls Signed-off-by: Yogeswaran K --- source/commonlib/telemetry_busmessage_sender.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/commonlib/telemetry_busmessage_sender.c b/source/commonlib/telemetry_busmessage_sender.c index 5dcfe0f7..a77515ce 100644 --- a/source/commonlib/telemetry_busmessage_sender.c +++ b/source/commonlib/telemetry_busmessage_sender.c @@ -761,6 +761,7 @@ static void *t2_init_worker(void *arg) { (void)arg; pthread_detach(pthread_self()); + EVENT_ERROR("%s ++in\n", __FUNCTION__); initMutex(); @@ -774,6 +775,7 @@ static void *t2_init_worker(void *arg) } isT2InitComplete = true; + EVENT_ERROR("%s --out\n", __FUNCTION__); return NULL; } @@ -783,6 +785,7 @@ static void *t2_init_worker(void *arg) void t2_init(char *component) { pthread_t initThread; + EVENT_ERROR("%s ++in\n", __FUNCTION__); componentName = strdup(component); if(pthread_create(&initThread, NULL, t2_init_worker, NULL) != 0) @@ -790,6 +793,7 @@ void t2_init(char *component) EVENT_ERROR("%s:%d, T2:Failed to create init worker thread, falling back to sync init\n", __func__, __LINE__); t2_init_worker(NULL); } + EVENT_ERROR("%s --out\n", __FUNCTION__); } void t2_uninit(void) From 49d8308002098b533ccbabb9272bc1071d116481 Mon Sep 17 00:00:00 2001 From: Yogeswaran K Date: Mon, 6 Jul 2026 13:06:06 +0000 Subject: [PATCH 7/7] RDKEMW-19134: Synchronizing t2_init with t2_event calls Signed-off-by: Yogeswaran K --- .../commonlib/telemetry_busmessage_sender.c | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/source/commonlib/telemetry_busmessage_sender.c b/source/commonlib/telemetry_busmessage_sender.c index a77515ce..ba463d9a 100644 --- a/source/commonlib/telemetry_busmessage_sender.c +++ b/source/commonlib/telemetry_busmessage_sender.c @@ -821,8 +821,20 @@ T2ERROR t2_event_s(const char* marker, const char* value) char* strvalue = NULL; if(!isT2InitComplete) { - EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); - return T2ERROR_FAILURE; + EVENT_ERROR("%s:%d, T2:t2_init is not complete, caching event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + if(marker && value && strlen(value) > 0 && strcmp(value, "0") != 0) + { + int eventDataLen = strlen(marker) + strlen(value) + strlen(MESSAGE_DELIMITER) + 1; + char* buffer = (char*) malloc(eventDataLen * sizeof(char)); + if(buffer) + { + pthread_t tid; + snprintf(buffer, eventDataLen, "%s%s%s", marker, MESSAGE_DELIMITER, value); + initMutex(); + pthread_create(&tid, NULL, cacheEventToFile, (void *)buffer); + } + } + return T2ERROR_SUCCESS; } if(componentName == NULL) { @@ -873,8 +885,21 @@ T2ERROR t2_event_f(const char* marker, double value) if(!isT2InitComplete) { - EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); - return T2ERROR_FAILURE; + EVENT_ERROR("%s:%d, T2:t2_init is not complete, caching event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + if(marker) + { + char *buffer = (char*) malloc(MAX_DATA_LEN * sizeof(char)); + if(buffer) + { + pthread_t tid; + char valStr[64] = { '\0' }; + snprintf(valStr, sizeof(valStr), "%f", value); + snprintf(buffer, MAX_DATA_LEN, "%s%s%s", marker, MESSAGE_DELIMITER, valStr); + initMutex(); + pthread_create(&tid, NULL, cacheEventToFile, (void *)buffer); + } + } + return T2ERROR_SUCCESS; } if(componentName == NULL) { @@ -922,8 +947,21 @@ T2ERROR t2_event_d(const char* marker, int value) if(!isT2InitComplete) { - EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL"); - return T2ERROR_FAILURE; + EVENT_ERROR("%s:%d, T2:t2_init is not complete, caching event %s\n", __func__, __LINE__, marker ? marker : "NULL"); + if(marker && value != 0) + { + char *buffer = (char*) malloc(MAX_DATA_LEN * sizeof(char)); + if(buffer) + { + pthread_t tid; + char valStr[64] = { '\0' }; + snprintf(valStr, sizeof(valStr), "%d", value); + snprintf(buffer, MAX_DATA_LEN, "%s%s%s", marker, MESSAGE_DELIMITER, valStr); + initMutex(); + pthread_create(&tid, NULL, cacheEventToFile, (void *)buffer); + } + } + return T2ERROR_SUCCESS; } if(componentName == NULL) {