RDKEMW-20646 : Using Thread::WorkerPool to send the events#320
Closed
karuna2git wants to merge 3 commits into
Closed
RDKEMW-20646 : Using Thread::WorkerPool to send the events#320karuna2git wants to merge 3 commits into
karuna2git wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent NetworkManager event publication from running in various caller thread contexts (NM event threads, connectivity thread, WiFi monitoring thread), by offloading notification dispatch to Thunder’s default worker pool to reduce lock contention and avoid GNOME NetworkManager instability.
Changes:
- Introduces an internal worker-pool
Joband adispatchEvent()/Dispatch()path to publish notification callbacks asynchronously. - Adds broad function-entry logging via
LOG_ENTRY_FUNCTION()across many APIs and helper paths. - Updates plugin/legacy configuration generation to use
*.conf.inautostart cache variables and bumps the plugin build to C++17.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/NetworkManagerLogger.h | Changes entry logging macro to include function name and log at INFO. |
| plugin/NetworkManagerImplementation.h | Adds event enum + worker-pool Job dispatcher plumbing. |
| plugin/NetworkManagerImplementation.cpp | Routes notification callbacks through worker pool; adds many entry logs; adjusts event logging. |
| plugin/NetworkManager.config | Removed legacy generated config template. |
| plugin/NetworkManager.conf.in | Makes autostart configurable via CMake cache variable. |
| plugin/CMakeLists.txt | Adds autostart cache variable; bumps C++ standard to 17 for plugin targets. |
| legacy/LegacyWiFiManagerAPIs.config | Removed legacy generated config template. |
| legacy/LegacyWiFiManagerAPIs.conf.in | Makes autostart configurable via CMake cache variable. |
| legacy/LegacyNetworkAPIs.config | Removed legacy generated config template. |
| legacy/LegacyNetworkAPIs.conf.in | Makes autostart configurable via CMake cache variable. |
| legacy/CMakeLists.txt | Adds autostart cache variables for legacy plugins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+730
to
+738
| case NM_ON_AVAILABLESSIDS: | ||
| { | ||
| string jsonOfFilterScanResults; | ||
| parameters.ToString(jsonOfFilterScanResults); | ||
| for (const auto callback : _notificationCallbacks) { | ||
| callback->onAvailableSSIDs(jsonOfFilterScanResults); | ||
| } | ||
| } | ||
| break; |
Comment on lines
+981
to
985
| { | ||
| JsonObject parameters; | ||
| parameters.FromString(jsonOfFilterScanResults); | ||
| dispatchEvent(NM_ON_AVAILABLESSIDS, parameters); | ||
| } |
Comment on lines
+224
to
231
| Job(NetworkManagerImplementation *NetworkManagerImplementation, NMPublishEvents event, JsonObject ¶ms) | ||
| : m_jobNWImpl(NetworkManagerImplementation) | ||
| , _event(event) | ||
| , _params(params) { | ||
| if (m_jobNWImpl != nullptr) { | ||
| m_jobNWImpl->AddRef(); | ||
| } | ||
| } |
Comment on lines
+247
to
+249
| virtual void Dispatch() { | ||
| m_jobNWImpl->Dispatch(_event, _params); | ||
| } |
| #define NMLOG_FATAL(FMT, ...) logPrint(NetworkManagerLogger::FATAL_LEVEL, __FILE__,__func__, __LINE__, FMT, ##__VA_ARGS__) | ||
|
|
||
| #define LOG_ENTRY_FUNCTION() { NMLOG_DEBUG("Entering"); } | ||
| #define LOG_ENTRY_FUNCTION() { NMLOG_INFO("Entering %s", __func__); } |
Comment on lines
+687
to
+691
| NMLOG_INFO("Posting %d Event\n", event); | ||
| _notificationLock.Lock(); | ||
| switch(event) | ||
| { | ||
| case NM_ON_INTERFACESTATE_CHANGE: |
Reason for change: All the NetworkManager Events are published from the calling thread context; somethings are from NMEvent, NMThread, somethings are from Connectivity thread and WiFiQualityMonitoring thread. When consumer is not responding properly, this will lead to extended lock & Sometimes Gnome NetworkManager Crash. To avoid this, all the events are sent thro Thread::WorkerPool that is default created by the Thunder. Test Procedure: Verify All the Networking Events Risks: Medium Signed-off-by: Karunakaran A <karunakaran_amirthalingam@cable.comcast.com>
a4e4f4d to
9f1d8de
Compare
Reason for change: fix deepsleep reconnect failure due to "wpa_cli status" returning empty BSSID, which cleared last SSID. Test procedure: WiFi should reconnect on DeepSleep wakeup Risks: low Priority: P1 Signed-off-by: Anand N <Anand_N@comcast.com>
| #define NMLOG_FATAL(FMT, ...) logPrint(NetworkManagerLogger::FATAL_LEVEL, __FILE__,__func__, __LINE__, FMT, ##__VA_ARGS__) | ||
|
|
||
| #define LOG_ENTRY_FUNCTION() { NMLOG_DEBUG("Entering"); } | ||
| #define LOG_ENTRY_FUNCTION() { NMLOG_INFO("Entering %s", __func__); } |
Comment on lines
+224
to
+251
| Job(NetworkManagerImplementation *NetworkManagerImplementation, NMPublishEvents event, JsonObject ¶ms) | ||
| : m_jobNWImpl(NetworkManagerImplementation) | ||
| , _event(event) | ||
| , _params(params) { | ||
| if (m_jobNWImpl != nullptr) { | ||
| m_jobNWImpl->AddRef(); | ||
| } | ||
| } | ||
| void Dispatch() override | ||
| { | ||
| _work(); | ||
|
|
||
| public: | ||
| Job() = delete; | ||
| Job(const Job&) = delete; | ||
| Job& operator=(const Job&) = delete; | ||
| ~Job() { | ||
| if (m_jobNWImpl != nullptr) { | ||
| m_jobNWImpl->Release(); | ||
| } | ||
| } | ||
|
|
||
| public: | ||
| static Core::ProxyType<Core::IDispatch> Create(NetworkManagerImplementation *pNWImpl, NMPublishEvents event, JsonObject params) { | ||
| return (Core::ProxyType<Core::IDispatch>(Core::ProxyType<Job>::Create(pNWImpl, event, params))); | ||
| } | ||
| virtual void Dispatch() { | ||
| if (m_jobNWImpl != nullptr) { | ||
| m_jobNWImpl->Dispatch(_event, _params); | ||
| } | ||
| } |
| void NetworkManagerImplementation::Dispatch(NMPublishEvents event, const JsonObject ¶meters) | ||
| { | ||
| LOG_ENTRY_FUNCTION(); | ||
| NMLOG_INFO("Posting %d Event\n", event); |
Comment on lines
+766
to
+779
| case NM_ON_WIFISIGNALQUALITY_CHANGE: | ||
| { | ||
| string ssid = parameters["ssid"].String(); | ||
| Exchange::INetworkManager::WiFiSignalQuality quality = static_cast <Exchange::INetworkManager::WiFiSignalQuality>(parameters["quality"].Number()); | ||
| int snr = parameters["snr"].Number(); | ||
| int strength = parameters["strength"].Number(); | ||
| int noise = parameters["noise"].Number(); | ||
| for (const auto callback : callbacks) { | ||
| callback->onWiFiSignalQualityChange(ssid, strength, noise, snr, quality); | ||
| callback->Release(); | ||
| } | ||
| } | ||
| break; | ||
| } |
Comment on lines
+843
to
+847
| { | ||
| Core::JSON::EnumType<Exchange::INetworkManager::InterfaceState> iState{state}; | ||
| JsonObject parameters; | ||
| parameters["state"] = JsonValue(state); | ||
| parameters["interface"] = interface; |
| @@ -618,10 +627,10 @@ namespace WPEFramework | |||
|
|
|||
| double frequencyValue = std::stod(frequency); | |||
Comment on lines
+1010
to
1014
| { | ||
| JsonObject parameters; | ||
| parameters.FromString(jsonOfFilterScanResults); | ||
| dispatchEvent(NM_ON_AVAILABLESSIDS, parameters); | ||
| } |
Comment on lines
+749
to
+750
| string jsonOfFilterScanResults; | ||
| parameters.ToString(jsonOfFilterScanResults); |
Comment on lines
+1331
to
+1332
| JsonObject parameters; | ||
| Core::JSON::EnumType<Exchange::INetworkManager::WiFiState> iState{state}; |
Comment on lines
+633
to
636
| for (const auto& selectedFrequency : filterFrequencies) | ||
| { | ||
| if (selectedFrequency == "ALL") | ||
| { |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Reason for change: All the NetworkManager Events are published from the calling thread context;
somethings are from NMEvent, NMThread, somethings are from Connectivity thread and WiFiQualityMonitoring thread.
When consumer is not responding properly, this will lead to extended lock & Sometimes Gnome NetworkManager Crash. To avoid this, all the events are sent thro Thread::WorkerPool that is default created by the Thunder.
Test Procedure: Verify All the Networking Events
Risks: Medium
Signed-off-by: Karunakaran A karunakaran_amirthalingam@cable.comcast.com