-
Notifications
You must be signed in to change notification settings - Fork 22
ISSUE-76 : Fix race condition during aggressive reloads #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e6b934f
1c72764
236cbcf
959ffaf
57ba0fd
0d9ead0
411e2c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's LICENSE file the | ||
| * following copyright and licenses apply: | ||
|
Check failure on line 3 in source/bulkdata/profilexconf.c
|
||
| * | ||
| * Copyright 2019 RDK Management | ||
| * | ||
|
|
@@ -47,6 +47,7 @@ | |
| static ProfileXConf *singleProfile = NULL; | ||
| static pthread_mutex_t plMutex; /* TODO - we can remove plMutex most likely but firseck that CollectAndReport doesn't cause issue */ | ||
| static pthread_cond_t reuseThread; | ||
| static pthread_t reportThread; // This is the thread that runs CollectAndReportXconf function | ||
| static bool reportThreadExits = false; | ||
|
|
||
| static pid_t xconfReportPid; | ||
|
|
@@ -220,6 +221,11 @@ | |
| do | ||
| { | ||
| T2Info("%s while Loop -- START \n", __FUNCTION__); | ||
| if(singleProfile == NULL) | ||
| { | ||
| T2Error("%s is called with empty profile, profile reload might be in-progress, skip the request\n", __FUNCTION__); | ||
| goto reportXconfThreadEnd; | ||
| } | ||
| profile = singleProfile; | ||
| Vector *profileParamVals = NULL; | ||
| Vector *grepResultList = NULL; | ||
|
|
@@ -494,7 +500,6 @@ | |
| //pthread_mutex_unlock(&plMutex); | ||
| reportXconfThreadEnd : | ||
| T2Info("%s while Loop -- END \n", __FUNCTION__); | ||
| T2Info("%s --out\n", __FUNCTION__); | ||
| pthread_cond_wait(&reuseThread, &plMutex); | ||
| } | ||
| while(initialized); | ||
|
|
@@ -591,7 +596,7 @@ | |
| pthread_mutex_lock(&plMutex); | ||
| pthread_cond_signal(&reuseThread); | ||
| pthread_mutex_unlock(&plMutex); | ||
| pthread_join(singleProfile->reportThread, NULL); | ||
| pthread_join(reportThread, NULL); | ||
shibu-kv marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coverity issue no longer present as of: undefined Show issueCoverity Issue - Data race conditionAccessing "reportThread" without holding lock "plMutex". Elsewhere, "reportThread" is written to with "plMutex" held 1 out of 1 times. Medium Impact, CWE-366
shivabhaskar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| reportThreadExits = false; | ||
shivabhaskar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| singleProfile->reportInProgress = false ; | ||
| T2Info("Final report is completed, releasing profile memory\n"); | ||
|
|
@@ -727,17 +732,7 @@ | |
|
|
||
| if(singleProfile->reportInProgress) | ||
| { | ||
| T2Info("Waiting for CollectAndReport to be complete : %s\n", singleProfile->name); | ||
| pthread_mutex_lock(&plMutex); | ||
| initialized = false; | ||
| T2Info("Sending signal to reuse Thread in CollectAndReportXconf\n"); | ||
| pthread_cond_signal(&reuseThread); | ||
| pthread_mutex_unlock(&plMutex); | ||
| pthread_join(singleProfile->reportThread, NULL); | ||
| T2Info("reportThread exits and initialising the profile list\n"); | ||
| reportThreadExits = false; | ||
| initialized = true; | ||
| singleProfile->reportInProgress = false ; | ||
| T2Info("Waiting for CollectAndReportXconf to be complete : %s\n", singleProfile->name); | ||
| } | ||
|
|
||
| pthread_mutex_lock(&plMutex); | ||
|
|
@@ -906,7 +901,7 @@ | |
| } | ||
| else | ||
| { | ||
| reportThreadStatus = pthread_create(&singleProfile->reportThread, NULL, CollectAndReportXconf, NULL); | ||
| reportThreadStatus = pthread_create(&reportThread, NULL, CollectAndReportXconf, NULL); | ||
| if ( reportThreadStatus != 0 ) | ||
| { | ||
| T2Error("Failed to create report thread with error code = %d !!! \n", reportThreadStatus); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.