Skip to content

Commit

Permalink
address the review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Dec 3, 2024
1 parent 0b938da commit e23edb0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
70 changes: 35 additions & 35 deletions NetworkManagerConnectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ namespace WPEFramework

doContinuousMonitor = false;
doConnectivityMonitor = false;
gInternetState = nsm_internetState::UNKNOWN;
gIpv4InternetState = nsm_internetState::UNKNOWN;
gIpv6InternetState = nsm_internetState::UNKNOWN;
m_InternetState = nsm_internetState::UNKNOWN;
m_Ipv4InternetState = nsm_internetState::UNKNOWN;
m_Ipv6InternetState = nsm_internetState::UNKNOWN;
}

ConnectivityMonitor::~ConnectivityMonitor()
Expand Down Expand Up @@ -389,15 +389,15 @@ namespace WPEFramework
// If monitor connectivity is running take the cache value

if ( doContinuousMonitor && (nsm_ipversion::NSM_IPRESOLVE_V4 == ipversion || nsm_ipversion::NSM_IPRESOLVE_WHATEVER == ipversion)
&& gIpv4InternetState != nsm_internetState::UNKNOWN ) {
NMLOG_WARNING("Reading Ipv4 internet state cached value %s", getInternetStateString(gIpv4InternetState));
internetState = gIpv4InternetState;
&& m_Ipv4InternetState != nsm_internetState::UNKNOWN ) {
NMLOG_WARNING("Reading Ipv4 internet state cached value %s", getInternetStateString(m_Ipv4InternetState));
internetState = m_Ipv4InternetState;
ipversion = NSM_IPRESOLVE_V4;
}
else if ( doContinuousMonitor && (nsm_ipversion::NSM_IPRESOLVE_V6 == ipversion || nsm_ipversion::NSM_IPRESOLVE_WHATEVER == ipversion)
&& gIpv6InternetState != nsm_internetState::UNKNOWN ) {
NMLOG_WARNING("Reading Ipv6 internet state cached value %s", getInternetStateString(gIpv6InternetState));
internetState = gIpv6InternetState;
&& m_Ipv6InternetState != nsm_internetState::UNKNOWN ) {
NMLOG_WARNING("Reading Ipv6 internet state cached value %s", getInternetStateString(m_Ipv6InternetState));
internetState = m_Ipv6InternetState;
ipversion = NSM_IPRESOLVE_V6;
}
else
Expand All @@ -424,7 +424,7 @@ namespace WPEFramework

bool ConnectivityMonitor::startContinuousConnectivityMonitor(int timeoutInSeconds)
{
NMLOG_INFO("interface status eth - %s wlan - %s ", _instance->isEthConnected? "up":"down", _instance->isWlanConnected? "up":"down");
NMLOG_INFO("interface status eth - %s wlan - %s ", _instance->m_ethConnected? "up":"down", _instance->m_wlanConnected? "up":"down");
continuousMonitorTimeout.store(timeoutInSeconds >= NMCONNECTIVITY_MONITOR_MIN_INTERVAL ? timeoutInSeconds : NMCONNECTIVITY_MONITOR_DEFAULT_INTERVAL);
if (doContinuousMonitor)
{
Expand Down Expand Up @@ -474,9 +474,9 @@ namespace WPEFramework
*/
bool ConnectivityMonitor::startConnectivityMonitor()
{
gInternetState = UNKNOWN;
gIpv4InternetState = UNKNOWN;
gIpv6InternetState = UNKNOWN;
m_InternetState = nsm_internetState::UNKNOWN;
m_Ipv4InternetState = nsm_internetState::UNKNOWN;
m_Ipv6InternetState = nsm_internetState::UNKNOWN;
if (doConnectivityMonitor)
{
cvConnectivityMonitor.notify_one();
Expand All @@ -497,7 +497,7 @@ namespace WPEFramework
}

NMLOG_INFO("connectivity monitor started %d sec - eth %s - wlan %s",
NMCONNECTIVITY_MONITOR_MIN_INTERVAL, _instance->isEthConnected? "up":"down", _instance->isWlanConnected? "up":"down");
NMCONNECTIVITY_MONITOR_MIN_INTERVAL, _instance->m_ethConnected? "up":"down", _instance->m_wlanConnected? "up":"down");
return true;
}

Expand All @@ -509,8 +509,8 @@ namespace WPEFramework
NMLOG_INFO("notify internet state %s", getInternetStateString(newInternetState));
Exchange::INetworkManager::InternetStatus newState = static_cast<Exchange::INetworkManager::InternetStatus>(newInternetState);
_instance->ReportInternetStatusChange(oldState , newState);
gInternetState = newInternetState;
oldState = newState; // 'gInternetState' not exactly previous state, it may change to unknow when interface changed
m_InternetState = newInternetState;
oldState = newState; // 'm_InternetState' not exactly previous state, it may change to unknow when interface changed
}
else
NMLOG_FATAL("NetworkManagerImplementation Instance NULL notifyInternetStatusChange failed.");
Expand All @@ -526,11 +526,11 @@ namespace WPEFramework

do
{
if(!_instance->isEthConnected && !_instance->isWlanConnected) // no wifi no ethernet connected
if(!_instance->m_ethConnected && !_instance->m_wlanConnected) // no wifi no ethernet connected
{
NMLOG_DEBUG("no interface connected; no ccm check");
gIpv4InternetState = NO_INTERNET;
gIpv6InternetState = NO_INTERNET;
m_Ipv4InternetState = NO_INTERNET;
m_Ipv6InternetState = NO_INTERNET;
std::unique_lock<std::mutex> lock(connMutex);
cvContinuousMonitor.wait_for(lock, std::chrono::seconds(continuousMonitorTimeout.load()));
ipResolveTyp = NSM_IPRESOLVE_WHATEVER;
Expand All @@ -540,17 +540,17 @@ namespace WPEFramework
if(doConnectivityMonitor)
{
NMLOG_DEBUG("connectivity monitor running so skiping ccm check");
gIpv4InternetState = UNKNOWN;
gIpv6InternetState = UNKNOWN;
m_Ipv4InternetState = nsm_internetState::UNKNOWN;
m_Ipv6InternetState = nsm_internetState::UNKNOWN;
std::unique_lock<std::mutex> lock(connMutex);
cvContinuousMonitor.wait_for(lock, std::chrono::seconds(continuousMonitorTimeout.load()));
ipResolveTyp = NSM_IPRESOLVE_WHATEVER; /* some interface change happense */
continue;
}
else if (ipResolveTyp == NSM_IPRESOLVE_WHATEVER)
{
nsm_internetState ipV4InternetState = UNKNOWN;
nsm_internetState ipV6InternetState = UNKNOWN;
nsm_internetState ipV4InternetState = nsm_internetState::UNKNOWN;
nsm_internetState ipV6InternetState = nsm_internetState::UNKNOWN;
auto curlCheckThrdIpv4 = [&]() {
TestConnectivity testInternet(getConnectivityMonitorEndpoints(), NMCONNECTIVITY_CURL_REQUEST_TIMEOUT_MS,
NMCONNECTIVITY_CURL_GET_REQUEST, NSM_IPRESOLVE_V4);
Expand Down Expand Up @@ -586,17 +586,17 @@ namespace WPEFramework
NMCONNECTIVITY_CURL_HEAD_REQUEST, ipResolveTyp);
currentInternetState = testInternet.getInternetState();
if(ipResolveTyp == NSM_IPRESOLVE_V4)
gIpv4InternetState = currentInternetState;
m_Ipv4InternetState = currentInternetState;
else if(ipResolveTyp == NSM_IPRESOLVE_V6)
gIpv6InternetState = currentInternetState;
m_Ipv6InternetState = currentInternetState;
}

if (currentInternetState == NO_INTERNET)
{
if(gInternetState == FULLY_CONNECTED && notifyPreRetry < NMCONNECTIVITY_NO_INTERNET_RETRY_COUNT)
if(m_InternetState == FULLY_CONNECTED && notifyPreRetry < NMCONNECTIVITY_NO_INTERNET_RETRY_COUNT)
{
/* it will prevent posting notification */
currentInternetState = gInternetState;
currentInternetState = m_InternetState;
TempInterval = 5;
NMLOG_INFO("No internet retrying connection check %d ...", notifyPreRetry);
notifyPreRetry++;
Expand All @@ -614,7 +614,7 @@ namespace WPEFramework
TempInterval = continuousMonitorTimeout.load();
}

if(gInternetState != currentInternetState)
if(m_InternetState != currentInternetState)
{
/* Notify Internet state change */
notifyInternetStatusChangedEvent(currentInternetState);
Expand All @@ -631,8 +631,8 @@ namespace WPEFramework

} while(doContinuousMonitor);

gIpv4InternetState = UNKNOWN;
gIpv6InternetState = UNKNOWN;
m_Ipv4InternetState = nsm_internetState::UNKNOWN;
m_Ipv6InternetState = nsm_internetState::UNKNOWN;
NMLOG_DEBUG("continous connectivity monitor exit");
}

Expand Down Expand Up @@ -675,8 +675,8 @@ namespace WPEFramework
NMLOG_INFO("Connectivity check retrying %d ...", notifyPreRetry);
}

if(gInternetState != UNKNOWN)
currentInternetState = gInternetState;
if(m_InternetState != nsm_internetState::UNKNOWN)
currentInternetState = m_InternetState;
TempInterval = 5;
}
else if(tempInternetState != currentInternetState) // last state have change
Expand All @@ -693,7 +693,7 @@ namespace WPEFramework
doConnectivityMonitor = false; // self exit
notifyNow = true; // post current state when retry complete
}
else if(_instance->isEthConnected | _instance->isWlanConnected)
else if(_instance->m_ethConnected | _instance->m_wlanConnected)
{
/* interface is connected and still no internet, continue check every 30 sec */
TempInterval = NMCONNECTIVITY_CONN_MONITOR_RETRY_INTERVAL;
Expand All @@ -712,7 +712,7 @@ namespace WPEFramework
}
}

if(gInternetState != currentInternetState || notifyNow)
if(m_InternetState != currentInternetState || notifyNow)
{
notifyNow = false;
notifyInternetStatusChangedEvent(currentInternetState);
Expand All @@ -731,7 +731,7 @@ namespace WPEFramework
} while(doConnectivityMonitor);

if(!doContinuousMonitor)
gInternetState = nsm_internetState::UNKNOWN; // no continous monitor running reset to unknow
m_InternetState = nsm_internetState::UNKNOWN; // no continous monitor running reset to unknow
NMLOG_DEBUG("initial connectivity monitor exit");
}

Expand Down
6 changes: 3 additions & 3 deletions NetworkManagerConnectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ namespace WPEFramework

EndpointCache endpointCache;
std::mutex endpointMutex;
std::atomic<nsm_internetState> gInternetState;
std::atomic<nsm_internetState> gIpv4InternetState;
std::atomic<nsm_internetState> gIpv6InternetState;
std::atomic<nsm_internetState> m_InternetState;
std::atomic<nsm_internetState> m_Ipv4InternetState;
std::atomic<nsm_internetState> m_Ipv6InternetState;
};
} // namespace Plugin
} // namespace WPEFramework
4 changes: 2 additions & 2 deletions NetworkManagerGnomeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ namespace WPEFramework
if(ifaceStr == wifiname) {
interface.type = INTERFACE_TYPE_WIFI;
interface.name = wifiname;
isWlanConnected = interface.connected;
m_wlanConnected = interface.connected;
}
if(ifaceStr == ethname) {
interface.type = INTERFACE_TYPE_ETHERNET;
interface.name = ethname;
isEthConnected = interface.connected;
m_ethConnected = interface.connected;
}

interfaceList.push_back(interface);
Expand Down
14 changes: 7 additions & 7 deletions NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ namespace WPEFramework
m_stunCacheTimeout = 0;
m_defaultInterface = "";
m_publicIP = "";
isEthConnected = false;
isWlanConnected = false;
m_ethConnected = false;
m_wlanConnected = false;
}

NetworkManagerImplementation::~NetworkManagerImplementation()
Expand Down Expand Up @@ -526,15 +526,15 @@ namespace WPEFramework
// Start the connectivity monitor with 'false' to indicate the interface is down.
// The monitor will automatically exit after the retry attempts are completed, posting a 'noInternet' event.
if(interface == "eth0")
isEthConnected = false;
m_ethConnected = false;
else
isWlanConnected = false;
m_wlanConnected = false;
connectivityMonitor.startConnectivityMonitor();
}

/* Only the Ethernet connection status is changing here. The WiFi status is updated in the WiFi state callback. */
if(Exchange::INetworkManager::INTERFACE_LINK_UP == state && interface == "eth0")
isEthConnected = true;
m_ethConnected = true;

_notificationLock.Lock();
NMLOG_INFO("Posting onInterfaceChange %s - %u", interface.c_str(), (unsigned)state);
Expand Down Expand Up @@ -596,11 +596,11 @@ namespace WPEFramework
/* start signal strength monitor when wifi connected */
if(INetworkManager::WiFiState::WIFI_STATE_CONNECTED == state)
{
isWlanConnected = true;
m_wlanConnected = true;
m_wifiSignalMonitor.startWiFiSignalStrengthMonitor(DEFAULT_WIFI_SIGNAL_TEST_INTERVAL_SEC);
}
else
isWlanConnected = false; /* Any other state is considered as WiFi not connected. */
m_wlanConnected = false; /* Any other state is considered as WiFi not connected. */

_notificationLock.Lock();
NMLOG_INFO("Posting onWiFiStateChange (%d)", state);
Expand Down
4 changes: 2 additions & 2 deletions NetworkManagerImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ namespace WPEFramework
void ReportWiFiSignalStrengthChange(const string ssid, const string strength, const Exchange::INetworkManager::WiFiSignalQuality quality);

public:
std::atomic<bool> isEthConnected;
std::atomic<bool> isWlanConnected;
std::atomic<bool> m_ethConnected;
std::atomic<bool> m_wlanConnected;

private:
void platform_init();
Expand Down
4 changes: 2 additions & 2 deletions NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,11 @@ namespace WPEFramework
tmp.connected = ((list.interfaces[i].flags & IFF_RUNNING) != 0);
if ("eth0" == interfaceName) {
tmp.type = Exchange::INetworkManager::INTERFACE_TYPE_ETHERNET;
isEthConnected = tmp.connected;
m_ethConnected = tmp.connected;
}
else if ("wlan0" == interfaceName) {
tmp.type = Exchange::INetworkManager::INTERFACE_TYPE_WIFI;
isWlanConnected = tmp.connected;
m_wlanConnected = tmp.connected;
}

interfaceList.push_back(tmp);
Expand Down

0 comments on commit e23edb0

Please sign in to comment.