Skip to content

Move mutex and message bus initialization into t2_init#387

Open
yogeswaransky wants to merge 8 commits into
support/1.9from
feature/RDKEMW-19134
Open

Move mutex and message bus initialization into t2_init#387
yogeswaransky wants to merge 8 commits into
support/1.9from
feature/RDKEMW-19134

Conversation

@yogeswaransky

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 24, 2026 18:49
@yogeswaransky yogeswaransky requested a review from a team as a code owner June 24, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves mutex initialization and message bus initialization into t2_init(), so callers initialize shared synchronization primitives and the RBUS/CCSP bus handle upfront rather than during the first event send.

Changes:

  • Initialize all module mutexes in t2_init() via initMutex().
  • Attempt message bus initialization in t2_init() via initMessageBus(), logging and deferring retry to event send on failure.
  • Remove per-call initMutex() from t2_event_s().

Comment on lines 757 to 770
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;
}
}
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Copilot AI review requested due to automatic review settings June 26, 2026 10:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

Comment on lines 29 to 32
#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" );
Comment on lines 205 to 208
static T2ERROR initMessageBus( )
{
// EVENT_DEBUG("%s ++in\n", __FUNCTION__);
EVENT_ERROR("%s ++in\n", __FUNCTION__);
T2ERROR status = T2ERROR_SUCCESS;
Comment on lines +251 to 253
EVENT_ERROR("%s --out\n", __FUNCTION__);
return status;
}
Comment on lines 442 to 445
EVENT_DEBUG("%s ++in\n", __FUNCTION__);
EVENT_ERROR("%s ++in\n", __FUNCTION__);
if(!bus_handle)
{
Comment on lines 533 to 536
EVENT_DEBUG("%s --out with status %d \n", __FUNCTION__, status);
EVENT_ERROR("%s --out with status %d \n", __FUNCTION__, status);
return status;
}
Comment on lines 563 to 567
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);
Comment on lines 599 to 604
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)
{
Comment on lines 671 to 677
uint32_t t2ReadyStatus;
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)
Comment on lines 747 to 750
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);
Comment on lines 762 to 775
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;
}
}
Copilot AI review requested due to automatic review settings June 26, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

Comment on lines 29 to 32
#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" );
Comment on lines 671 to 676
uint32_t t2ReadyStatus;
rbusError_t retVal = RBUS_ERROR_SUCCESS;

retVal = rbus_getUint(bus_handle, T2_OPERATIONAL_STATUS, &t2ReadyStatus);
EVENT_ERROR("Retrieved T2 Operational status: %d\n", t2ReadyStatus);

Comment on lines +749 to 750
EVENT_ERROR("T2: Sending event : %s\n", telemetry_data);
ret = filtered_event_send(telemetry_data, markerName);
Comment on lines 442 to 444
EVENT_DEBUG("%s ++in\n", __FUNCTION__);
EVENT_ERROR("%s ++in\n", __FUNCTION__);
if(!bus_handle)
Comment on lines 533 to 536
EVENT_DEBUG("%s --out with status %d \n", __FUNCTION__, status);
EVENT_ERROR("%s --out with status %d \n", __FUNCTION__, status);
return status;
}
Comment on lines 205 to 208
static T2ERROR initMessageBus( )
{
// EVENT_DEBUG("%s ++in\n", __FUNCTION__);
EVENT_ERROR("%s ++in\n", __FUNCTION__);
T2ERROR status = T2ERROR_SUCCESS;
Comment on lines 249 to 252
}
#endif // CCSP_SUPPORT_ENABLED
// EVENT_DEBUG("%s --out\n", __FUNCTION__);
EVENT_ERROR("%s --out\n", __FUNCTION__);
return status;
Comment on lines 762 to 775
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;
}
}
Comment on lines 563 to 566
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]);

Comment on lines 600 to 603
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)
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (1)

source/commonlib/telemetry_busmessage_sender.c:449

  • When bus_handle is NULL this function currently returns ret (RBUS_ERROR_SUCCESS), which makes the caller think the send succeeded. Return a failure status consistently for the int return type.
    if(!bus_handle)
    {
        EVENT_ERROR("bus_handle is null .. exiting !!! \n");
        return ret;
    }

Comment on lines +791 to +795
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);
}
isRFCT2Enable = true;
}

isT2InitComplete = true;
Comment on lines 672 to +676
uint32_t t2ReadyStatus;
rbusError_t retVal = RBUS_ERROR_SUCCESS;

retVal = rbus_getUint(bus_handle, T2_OPERATIONAL_STATUS, &t2ReadyStatus);
EVENT_ERROR("Retrieved T2 Operational status: %d\n", t2ReadyStatus);
Comment on lines 748 to 751
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);
Comment on lines 29 to 32
#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" );
Comment on lines +822 to 831
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);
return T2ERROR_COMPONENT_NULL;
}
Comment on lines +874 to +878
if(!isT2InitComplete)
{
EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL");
return T2ERROR_FAILURE;
}
Comment on lines +923 to +927
if(!isT2InitComplete)
{
EVENT_DEBUG("%s:%d, T2:t2_init is not complete, dropping event %s\n", __func__, __LINE__, marker ? marker : "NULL");
return T2ERROR_FAILURE;
}
Comment on lines 789 to +792
componentName = strdup(component);

if(pthread_create(&initThread, NULL, t2_init_worker, NULL) != 0)
{
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants