Skip to content

Move mutex and message bus initialization into t2_init#387

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

Move mutex and message bus initialization into t2_init#387
yogeswaransky wants to merge 5 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)
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