From 72184aaefb9cbfff82c0d6d47ba635dbe9322919 Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:22:42 -0400 Subject: [PATCH 1/7] Update NetworkManagerGnomeProxy.cpp --- plugin/gnome/NetworkManagerGnomeProxy.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/gnome/NetworkManagerGnomeProxy.cpp b/plugin/gnome/NetworkManagerGnomeProxy.cpp index 932dd9a8..4fdccbe5 100644 --- a/plugin/gnome/NetworkManagerGnomeProxy.cpp +++ b/plugin/gnome/NetworkManagerGnomeProxy.cpp @@ -762,6 +762,9 @@ namespace WPEFramework { uint32_t rc = Core::ERROR_RPC_CALL_FAILED; + std::vector ssidsSnapshot; + + _filterVectorsLock.Lock(); //Cleared the Existing Store filterred SSID list m_filterSsidslist.clear(); m_filterFrequencies.clear(); @@ -801,6 +804,7 @@ namespace WPEFramework else { NMLOG_ERROR("Invalid frequency value: %s", frequency.c_str()); + _filterVectorsLock.Unlock(); return Core::ERROR_BAD_REQUEST; } } @@ -810,9 +814,11 @@ namespace WPEFramework } } } + ssidsSnapshot = m_filterSsidslist; + _filterVectorsLock.Unlock(); nmEvent->setwifiScanOptions(true); - if(wifi->wifiScanRequest(m_filterSsidslist)) + if(wifi->wifiScanRequest(ssidsSnapshot)) rc = Core::ERROR_NONE; return rc; } From ec8fb0dc49ba3af043e41ad2147a10349c0d6fa6 Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:23:27 -0400 Subject: [PATCH 2/7] Update NetworkManagerRDKProxy.cpp --- plugin/rdk/NetworkManagerRDKProxy.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/rdk/NetworkManagerRDKProxy.cpp b/plugin/rdk/NetworkManagerRDKProxy.cpp index b163ae3c..82ea9d1f 100644 --- a/plugin/rdk/NetworkManagerRDKProxy.cpp +++ b/plugin/rdk/NetworkManagerRDKProxy.cpp @@ -973,6 +973,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { IARM_Result_t retVal = IARM_RESULT_SUCCESS; //Cleared the Existing Store filterred SSID list + _filterVectorsLock.Lock(); m_filterSsidslist.clear(); m_filterFrequencies.clear(); if(ssids) @@ -994,6 +995,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { NMLOG_DEBUG("%s added to Frequency filtering", frequencyList.c_str()); } } + _filterVectorsLock.Unlock(); memset(¶m, 0, sizeof(param)); From 29c743a170b48ac8dbcfb9e14cbc8866e304a247 Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:28:54 -0400 Subject: [PATCH 3/7] Update NetworkManagerImplementation.cpp --- plugin/NetworkManagerImplementation.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin/NetworkManagerImplementation.cpp b/plugin/NetworkManagerImplementation.cpp index b10b375b..935d6454 100644 --- a/plugin/NetworkManagerImplementation.cpp +++ b/plugin/NetworkManagerImplementation.cpp @@ -738,7 +738,6 @@ namespace WPEFramework void NetworkManagerImplementation::ReportActiveInterfaceChange(const string prevActiveInterface, const string currentActiveinterface) { - _notificationLock.Lock(); NMLOG_INFO("Posting onActiveInterfaceChange %s", currentActiveinterface.c_str()); if(currentActiveinterface == "eth0") @@ -754,15 +753,15 @@ namespace WPEFramework // FIXME : This could be the place to define `m_defaultInterface` to incoming `currentActiveinterface`. // m_defaultInterface = currentActiveinterface; - + _notificationLock.Lock(); for (const auto callback : _notificationCallbacks) { callback->onActiveInterfaceChange(prevActiveInterface, currentActiveinterface); } + _notificationLock.Unlock(); #if USE_TELEMETRY NMLOG_INFO("NM_INTERFACE_STATUS = Interface changed to %s", currentActiveinterface.c_str()); logTelemetry("NM_INTERFACE_STATUS", "Interface changed to " + currentActiveinterface); -#endif - _notificationLock.Unlock(); +#endif } void NetworkManagerImplementation::ReportIPAddressChange(const string interface, const string ipversion, const string ipaddress, const Exchange::INetworkManager::IPStatus status) @@ -810,7 +809,6 @@ namespace WPEFramework void NetworkManagerImplementation::ReportInternetStatusChange(const Exchange::INetworkManager::InternetStatus prevState, const Exchange::INetworkManager::InternetStatus currState, const string interface) { - _notificationLock.Lock(); NMLOG_INFO("Posting onInternetStatusChange with current state as %u", (unsigned)currState); #if USE_TELEMETRY // Log error only when ethernet is up and there's no internet @@ -823,15 +821,16 @@ namespace WPEFramework logTelemetry("NM_ETHERNET_CONNECTIVITY", "Ethernet connectivity failed"); } #endif + _notificationLock.Lock(); for (const auto callback : _notificationCallbacks) { callback->onInternetStatusChange(prevState, currState, interface); } + _notificationLock.Unlock(); #if USE_TELEMETRY string stateStr = Core::EnumerateType(currState).Data(); NMLOG_INFO("NM_INTERNET_STATUS = %s", stateStr.c_str()); logTelemetry("NM_INTERNET_STATUS", stateStr); #endif - _notificationLock.Unlock(); } int32_t NetworkManagerImplementation::logSSIDs(Logging level, const JsonArray &ssids) @@ -855,7 +854,6 @@ namespace WPEFramework void NetworkManagerImplementation::ReportAvailableSSIDs(const JsonArray &arrayofWiFiScanResults) { - _notificationLock.Lock(); string jsonOfWiFiScanResults; string jsonOfFilterScanResults; JsonArray filterResult = arrayofWiFiScanResults; @@ -864,12 +862,15 @@ namespace WPEFramework NMLOG_DEBUG("Discovered %d SSIDs before filtering as,", filterResult.Length()); logSSIDs(LOG_LEVEL_DEBUG, filterResult); + _filterVectorsLock.Lock(); filterScanResults(filterResult); + _filterVectorsLock.Unlock(); filterResult.ToString(jsonOfFilterScanResults); NMLOG_INFO("Posting onAvailableSSIDs event with %d SSIDs as,", filterResult.Length()); logSSIDs(LOG_LEVEL_INFO, filterResult); + _notificationLock.Lock(); for (const auto callback : _notificationCallbacks) { callback->onAvailableSSIDs(jsonOfFilterScanResults); } @@ -1177,13 +1178,13 @@ namespace WPEFramework m_wlanConnected.store(false); /* Any other state is considered as WiFi not connected. */ } - _notificationLock.Lock(); NMLOG_INFO("Posting onWiFiStateChange (%d)", state); #if USE_TELEMETRY string stateStr = Core::EnumerateType(state).Data(); NMLOG_INFO("NM_WIFI_STATUS = %s", stateStr.c_str()); logTelemetry("NM_WIFI_STATUS", stateStr); #endif + _notificationLock.Lock(); for (const auto callback : _notificationCallbacks) { callback->onWiFiStateChange(state); } From d724ad691291658b6c2b48f39a30bcf2c98112fc Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:29:33 -0400 Subject: [PATCH 4/7] Update NetworkManagerImplementation.h --- plugin/NetworkManagerImplementation.h | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NetworkManagerImplementation.h b/plugin/NetworkManagerImplementation.h index 65baa0b1..4c888d64 100644 --- a/plugin/NetworkManagerImplementation.h +++ b/plugin/NetworkManagerImplementation.h @@ -348,6 +348,7 @@ namespace WPEFramework private: std::list _notificationCallbacks; Core::CriticalSection _notificationLock; + Core::CriticalSection _filterVectorsLock; string m_publicIP; stun::client stunClient; string m_stunEndpoint; From d757a803f7a14d36efce6da6cfe0882626db30dd Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:03:42 -0400 Subject: [PATCH 5/7] Update NetworkManagerImplementation.cpp --- plugin/NetworkManagerImplementation.cpp | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/plugin/NetworkManagerImplementation.cpp b/plugin/NetworkManagerImplementation.cpp index 935d6454..71fb827d 100644 --- a/plugin/NetworkManagerImplementation.cpp +++ b/plugin/NetworkManagerImplementation.cpp @@ -597,14 +597,16 @@ namespace WPEFramework return; } - void NetworkManagerImplementation::filterScanResults(JsonArray &ssids) + void NetworkManagerImplementation::filterScanResults(JsonArray &ssids, + const std::vector& filterSsidslist, + const std::vector& filterFrequencies) { JsonArray result; double filterFreq = 0.0; - std::unordered_set scanForSsidsSet(m_filterSsidslist.begin(), m_filterSsidslist.end()); + std::unordered_set scanForSsidsSet(filterSsidslist.begin(), filterSsidslist.end()); // If neither SSID list nor frequency is provided, exit - if (m_filterSsidslist.empty() && m_filterFrequencies.empty()) + if (filterSsidslist.empty() && filterFrequencies.empty()) { NMLOG_DEBUG("Neither SSID nor Frequency is provided. Exiting function."); return; @@ -618,10 +620,10 @@ namespace WPEFramework double frequencyValue = std::stod(frequency); bool ssidMatches = scanForSsidsSet.empty() || scanForSsidsSet.find(ssid) != scanForSsidsSet.end(); - bool freqMatches = m_filterFrequencies.empty(); + bool freqMatches = filterFrequencies.empty(); if (!freqMatches) { - for (const auto& selectedFrequency : m_filterFrequencies) + for (const auto& selectedFrequency : filterFrequencies) { if (selectedFrequency == "ALL") { @@ -862,9 +864,19 @@ namespace WPEFramework NMLOG_DEBUG("Discovered %d SSIDs before filtering as,", filterResult.Length()); logSSIDs(LOG_LEVEL_DEBUG, filterResult); - _filterVectorsLock.Lock(); - filterScanResults(filterResult); - _filterVectorsLock.Unlock(); + // Snapshot filter vectors under lock, then release before calling filterScanResults + // to ensure exception-safety (std::stod can throw). + std::vector ssidsSnapshot; + std::vector frequenciesSnapshot; + { + _filterVectorsLock.Lock(); + ssidsSnapshot = m_filterSsidslist; + frequenciesSnapshot = m_filterFrequencies; + _filterVectorsLock.Unlock(); + } + + // Call filterScanResults outside the lock with snapshots (exception-safe) + filterScanResults(filterResult, ssidsSnapshot, frequenciesSnapshot); filterResult.ToString(jsonOfFilterScanResults); NMLOG_INFO("Posting onAvailableSSIDs event with %d SSIDs as,", filterResult.Length()); From 43abfe7600df7bc4cc2302288333a5df45a825e6 Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:04:03 -0400 Subject: [PATCH 6/7] Update NetworkManagerImplementation.h --- plugin/NetworkManagerImplementation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NetworkManagerImplementation.h b/plugin/NetworkManagerImplementation.h index 4c888d64..e4b7895f 100644 --- a/plugin/NetworkManagerImplementation.h +++ b/plugin/NetworkManagerImplementation.h @@ -338,7 +338,7 @@ namespace WPEFramework void getInitialConnectionState(void); void executeExternally(NetworkEvents event, const string commandToExecute, string& response); void threadEventRegistration(bool iarmInit, bool iarmConnect); - void filterScanResults(JsonArray &ssids); + void filterScanResults(JsonArray &ssids, const std::vector& filterSsidslist, const std::vector& filterFrequencies); void startWiFiSignalQualityMonitor(int interval); void stopWiFiSignalQualityMonitor(); void monitorThreadFunction(int interval); From 065578bde544cbf64f781449b0c6abf51595464d Mon Sep 17 00:00:00 2001 From: jincysam87 <167995204+jincysam87@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:10:05 -0400 Subject: [PATCH 7/7] Update NetworkManagerLogger.h --- plugin/NetworkManagerLogger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NetworkManagerLogger.h b/plugin/NetworkManagerLogger.h index 4c35f1ab..ff1b1497 100644 --- a/plugin/NetworkManagerLogger.h +++ b/plugin/NetworkManagerLogger.h @@ -70,7 +70,7 @@ void logPrint(LogLevel level, const char* file, const char* func, int line, cons #define NMLOG_ERROR(FMT, ...) logPrint(NetworkManagerLogger::ERROR_LEVEL, __FILE__, __func__, __LINE__, FMT, ##__VA_ARGS__) #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"); } } // namespace NetworkManagerLogger