Skip to content

Commit

Permalink
connectivity monitor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Nov 22, 2024
1 parent c7f1673 commit f3facb3
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions NetworkManagerConnectivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ namespace WPEFramework
curl_easy_setopt(curl_easy_handle, CURLOPT_TIMEOUT_MS, deadline - current_time());
if ((ipversion == CURL_IPRESOLVE_V4) || (ipversion == CURL_IPRESOLVE_V6))
{
NMLOG_DEBUG("curlopt ipversion = %s reqtyp = %s", ipversion == CURL_IPRESOLVE_V4?"ipv4 only":"ipv6 only", headReq? "HEAD":"GET");
NMLOG_INFO("curlopt ipversion = %s reqtyp = %s", ipversion == CURL_IPRESOLVE_V4?"IPv4":"IPv6", headReq? "HEAD":"GET");
curl_easy_setopt(curl_easy_handle, CURLOPT_IPRESOLVE, ipversion);
}
else
{
NMLOG_DEBUG("curlopt ipversion = whatever reqtyp = %s", headReq? "HEAD":"GET");
NMLOG_INFO("curlopt ipversion = whatever reqtyp = %s", headReq? "HEAD":"GET");
}
if(curlVerboseEnabled())
curl_easy_setopt(curl_easy_handle, CURLOPT_VERBOSE, 1L);
Expand Down Expand Up @@ -503,15 +503,17 @@ namespace WPEFramework

void ConnectivityMonitor::notifyInternetStatusChangedEvent(nsm_internetState newInternetState)
{
static Exchange::INetworkManager::InternetStatus oldState = Exchange::INetworkManager::InternetStatus::INTERNET_UNKNOWN;
if(_instance != nullptr)
{
Exchange::INetworkManager::InternetStatus oldState = static_cast<Exchange::INetworkManager::InternetStatus>(gInternetState.load());
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
}
else
NMLOG_WARNING("NetworkManagerImplementation Instance NULL notifyInternetStatusChange failed.");
NMLOG_FATAL("NetworkManagerImplementation Instance NULL notifyInternetStatusChange failed.");
}

void ConnectivityMonitor::continuousMonitorFunction()
Expand All @@ -524,6 +526,22 @@ namespace WPEFramework

do
{
if(ginterfaceStatus == false)
{
NMLOG_DEBUG("no interface connected; no ccm check");
gIpv4InternetState = NO_INTERNET;
gIpv6InternetState = NO_INTERNET;
std::unique_lock<std::mutex> lock(connMutex);
cvContinuousMonitor.wait_for(lock, std::chrono::seconds(continuousMonitorTimeout.load()));
continue;
}
else
{
gIpv4InternetState = UNKNOWN;
gIpv6InternetState = UNKNOWN;
ipResolveTyp = NSM_IPRESOLVE_WHATEVER;
}

if(doConnectivityMonitor)
{
NMLOG_DEBUG("connectivity monitor running so skiping ccm check");
Expand Down Expand Up @@ -603,7 +621,6 @@ namespace WPEFramework

if(gInternetState != currentInternetState)
{
NMLOG_INFO("Internet state changed to %s", getInternetStateString(currentInternetState));
/* Notify Internet state change */
notifyInternetStatusChangedEvent(currentInternetState);
}
Expand Down Expand Up @@ -702,7 +719,6 @@ namespace WPEFramework
if(gInternetState != currentInternetState || notifyNow)
{
notifyNow = false;
NMLOG_INFO("notify internet state %s", getInternetStateString(currentInternetState));
notifyInternetStatusChangedEvent(currentInternetState);
}

Expand Down

0 comments on commit f3facb3

Please sign in to comment.