Move mutex and message bus initialization into t2_init#387
Open
yogeswaransky wants to merge 5 commits into
Open
Move mutex and message bus initialization into t2_init#387yogeswaransky wants to merge 5 commits into
yogeswaransky wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
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()viainitMutex(). - Attempt message bus initialization in
t2_init()viainitMessageBus(), logging and deferring retry to event send on failure. - Remove per-call
initMutex()fromt2_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>
Signed-off-by: Yogeswaran K <yogeswaransky@gmail.com>
…telemetry into feature/RDKEMW-19134
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; | ||
| } | ||
| } |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.