Skip to content

Commit c555c21

Browse files
udaykrishnagCopilot
authored andcommitted
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e6c6ff2 commit c555c21

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

networkstats/plugin/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ install(
116116
set(PLUGIN_NETWORKCONNECTIONSTATS_AUTOSTART "false" CACHE STRING "Automatically start the plugin")
117117
set(PLUGIN_NETWORKCONNECTIONSTATS_OUTOFPROCESS "true" CACHE STRING "Run plugin out-of-process")
118118
set(PLUGIN_NETWORKCONNECTIONSTATS_STARTUPORDER "50" CACHE STRING "Plugin startup order")
119-
set(PLUGIN_NETWORKCONNECTIONSTATS_REPORTING_INTERVAL "90" CACHE STRING "Reporting interval in seconds (default: 90 seconds)")
119+
set(PLUGIN_NETWORKCONNECTIONSTATS_REPORTING_INTERVAL "600" CACHE STRING "Reporting interval in seconds (default: 600 seconds)")
120120
set(PLUGIN_NETWORKCONNECTIONSTATS_PROVIDER_TYPE "comrpc" CACHE STRING "Network data provider type: 'comrpc' or 'jsonrpc' (default: comrpc)")
121121

122122
# Install configuration

networkstats/plugin/NetworkConnectionStatsImplementation.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using namespace NetworkConnectionStatsLogger;
3131
namespace WPEFramework {
3232
namespace Plugin {
3333

34-
SERVICE_REGISTRATION(NetworkConnectionStatsImplementation, 1, 0);
34+
SERVICE_REGISTRATION(NetworkConnectionStatsImplementation, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
3535

3636
NetworkConnectionStatsImplementation::NetworkConnectionStatsImplementation()
3737
: _adminLock()
@@ -52,8 +52,8 @@ namespace Plugin {
5252
, m_subsIPAddrChange(false)
5353
{
5454

55-
NSLOG_INFO("NetworkConnectionStatsImplemen tation Constructor");
56-
/* Set NetworkManager Out-Process name to be NWMgrPlugin */
55+
NSLOG_INFO("NetworkConnectionStatsImplementation Constructor");
56+
/* Set NetworkManager Out-Process name to be "NetworkConnectionStats" */
5757
Core::ProcessInfo().Name("NetworkConnectionStats");
5858
NSLOG_INFO((_T("NetworkConnectionStats Out-Of-Process Instantiation; SHA: " _T(EXPAND_AND_QUOTE(PLUGIN_BUILD_REFERENCE)))));
5959
#if USE_TELEMETRY
@@ -205,6 +205,9 @@ namespace Plugin {
205205
auto factoryType = NetworkDataProviderFactory::ParseProviderType(providerType);
206206
std::string typeName = NetworkDataProviderFactory::GetProviderTypeName(factoryType);
207207
NSLOG_ERROR("Failed to initialize %s provider", typeName.c_str());
208+
// Clean up the partially initialized provider to prevent leaks and later accidental use
209+
delete m_provider;
210+
m_provider = nullptr;
208211
result = Core::ERROR_GENERAL;
209212
}
210213
}
@@ -292,7 +295,7 @@ namespace Plugin {
292295

293296
void NetworkConnectionStatsImplementation::logTelemetry(const std::string& eventName, const std::string& message)
294297
{
295-
NSLOG_INFO("NS_T2: %s:%s", eventName.c_str(), message.c_str());
298+
//NSLOG_INFO("NS_T2: %s:%s", eventName.c_str(), message.c_str());
296299
#if USE_TELEMETRY
297300
T2ERROR t2error = t2_event_s(eventName.c_str(), (char*)message.c_str());
298301
if (t2error != T2ERROR_SUCCESS) {
@@ -383,7 +386,7 @@ namespace Plugin {
383386
std::string packetLoss = m_provider->getPacketLoss();
384387
std::string avgRtt = m_provider->getAvgRtt();
385388
if (success) {
386-
NSLOG_INFO("IPv4 gateway ping - Loss: %s%%, RTT: %sms",
389+
NSLOG_INFO("IPv4 gateway ping Loss: %s%%, RTT: %s",
387390
packetLoss.c_str(), avgRtt.c_str());
388391

389392
logTelemetry("IPv4_Gateway_Packet_Loss", packetLoss);
@@ -407,7 +410,7 @@ namespace Plugin {
407410
std::string packetLoss = m_provider->getPacketLoss();
408411
std::string avgRtt = m_provider->getAvgRtt();
409412
if (success) {
410-
NSLOG_INFO("IPv6 gateway ping - Loss: %s%%, RTT: %sms",
413+
NSLOG_INFO("IPv6 gateway ping Loss: %s%%, RTT: %s",
411414
packetLoss.c_str(), avgRtt.c_str());
412415

413416
logTelemetry("IPv6_Gateway_Packet_Loss", packetLoss);

0 commit comments

Comments
 (0)