-
Notifications
You must be signed in to change notification settings - Fork 52
RDKEMW-12282: Fix Coverity identified issues - dobby #405
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
9dc285d
bb782fd
8ba7846
9388819
f75dfe6
9756bc7
1a532ab
161d7b0
7832785
60aac7c
06a0de3
f6adb02
b39b464
c1c6dbd
2730884
e0d2038
ad315d1
a495ad9
f5138f9
b7d7f2f
03f92fe
9756d4a
dc87f41
2077a4e
572c7b3
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,10 @@ using namespace AICommon; | |||||||||||
|
|
||||||||||||
| Timer::~Timer() | ||||||||||||
| { | ||||||||||||
| cancel(); | ||||||||||||
| try { | ||||||||||||
| cancel(); | ||||||||||||
| } catch (const std::exception& e) { | ||||||||||||
| } | ||||||||||||
|
Comment on lines
+35
to
+38
|
||||||||||||
| try { | |
| cancel(); | |
| } catch (const std::exception& e) { | |
| } | |
| cancel(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,7 +195,6 @@ class Notifier : virtual public Polymorphic | |
| { | ||
| cv.notify_all(); | ||
| } | ||
| lock.unlock(); | ||
| } | ||
|
|
||
| protected: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -164,11 +164,13 @@ bool DobbyBundleConfig::isValid() const | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| uid_t DobbyBundleConfig::userId() const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | ||||||||||||||||||||||||||||
| return mUserId; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| gid_t DobbyBundleConfig::groupId() const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | ||||||||||||||||||||||||||||
| return mGroupId; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -239,11 +241,13 @@ void DobbyBundleConfig::setUidGidMappings(uid_t userId, gid_t groupId) | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const std::string& DobbyBundleConfig::rootfsPath() const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | ||||||||||||||||||||||||||||
| return mRootfsPath; | ||||||||||||||||||||||||||||
dkumar798 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
dkumar798 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| bool DobbyBundleConfig::restartOnCrash() const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | ||||||||||||||||||||||||||||
| return mRestartOnCrash; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -286,6 +290,7 @@ const std::map<std::string, Json::Value>& DobbyBundleConfig::legacyPlugins() con | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const std::map<std::string, Json::Value>& DobbyBundleConfig::rdkPlugins() const | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | ||||||||||||||||||||||||||||
| return mRdkPlugins; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| std::lock_guard<std::mutex> locker(mLock); | |
| return mRdkPlugins; | |
| // Create a thread-local copy of the plugin map so that callers | |
| // receive a reference to per-thread data that is not modified | |
| // concurrently by other threads. | |
| thread_local std::map<std::string, Json::Value> rdkPluginsCopy; | |
| { | |
| std::lock_guard<std::mutex> locker(mLock); | |
| rdkPluginsCopy = mRdkPlugins; | |
| } | |
| return rdkPluginsCopy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ThreadedDispatcher::hasMoreWorkOrWasStopRequested() now takes m, but it is used as the predicate for cv.wait(lock, pred) while the caller already holds the same mutex. This will self-deadlock when the predicate tries to lock m again. Remove the internal locking from the predicate (assume the caller holds m), or provide two helpers: one that requires m held for the condition_variable predicate and another public method that locks when called externally.