From 2322622e39557671a7254fa29fbfb96eed86066e Mon Sep 17 00:00:00 2001 From: Rangaiah Date: Thu, 12 Dec 2024 12:12:58 +0530 Subject: [PATCH] Reduce webpa sync notification retry attempts --- source/broadband/include/webpa_notification.h | 1 + source/broadband/webpa_notification.c | 51 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/source/broadband/include/webpa_notification.h b/source/broadband/include/webpa_notification.h index a0e7bcaa..c2a92458 100644 --- a/source/broadband/include/webpa_notification.h +++ b/source/broadband/include/webpa_notification.h @@ -15,6 +15,7 @@ /* Macros */ /*----------------------------------------------------------------------------*/ #define FACTORY_RESET_NOTIFY_MAX_RETRY_COUNT 5 +#define SYNC_NOTIFY_MAX_RETRY_COUNT 5 #define XPC_CID "61f4db9" #if defined(BUILD_YOCTO) #define WEBPA_CFG_FILE "/nvram/webpa_cfg.json" diff --git a/source/broadband/webpa_notification.c b/source/broadband/webpa_notification.c index e7223188..70626f7e 100644 --- a/source/broadband/webpa_notification.c +++ b/source/broadband/webpa_notification.c @@ -388,25 +388,21 @@ void *SyncNotifyRetry() pthread_detach(pthread_self()); char *dbCMC = NULL; int backoffRetryTime = 0; - int backoff_max_time = 9; + int retryCount = 0; struct timespec ts; - int c = 3; + int c = 120; int rv; - int max_retry_sleep = (int) pow(2, backoff_max_time) -1; - WalInfo("SyncNotifyRetry: max_retry_sleep is %d\n", max_retry_sleep ); - + bool EnableSyncNotifyFlag = 1; + while(FOREVER()) { - if(backoffRetryTime < max_retry_sleep) - { - backoffRetryTime = (int) pow(2, c) -1; - } + backoffRetryTime = (int) (1 << retryCount)*c+1; clock_gettime(CLOCK_REALTIME, &ts); ts.tv_sec += backoffRetryTime; //wait for backoff delay for retransmission if(g_checkSyncNotifyRetry == 1) { - WalInfo("Wait for backoffRetryTime %d sec to check sync notification retry\n", backoffRetryTime); + WalInfo("Wait for backoffRetryTime %d sec to check sync notification retry, retryCount=%d\n", backoffRetryTime,retryCount); } rv = pthread_cond_timedwait(&sync_condition, &sync_mutex, &ts); @@ -448,29 +444,34 @@ void *SyncNotifyRetry() { //Retry sending sync notification to cloud WalInfo("Retrying sync notification as cloud and CPE are out of sync, dbCMC is %s\n", dbCMC); - NotifyData *notifyData = (NotifyData *)malloc(sizeof(NotifyData) * 1); - if(notifyData != NULL) + if(EnableSyncNotifyFlag == 1) { - memset(notifyData,0,sizeof(NotifyData)); - notifyData->type = PARAM_NOTIFY_RETRY; - processNotification(notifyData); + NotifyData *notifyData = (NotifyData *)malloc(sizeof(NotifyData) * 1); + if(notifyData != NULL) + { + memset(notifyData,0,sizeof(NotifyData)); + notifyData->type = PARAM_NOTIFY_RETRY; + processNotification(notifyData); + } + WalInfo("After Sending processNotification\n"); } - WalPrint("After Sending processNotification\n"); - c++; - if(backoffRetryTime == max_retry_sleep) - { - c = 3; - backoffRetryTime = 0; - WalPrint("backoffRetryTime reached max value, reseting to initial value\n"); - } + retryCount++; + if(retryCount == SYNC_NOTIFY_MAX_RETRY_COUNT) + { + EnableSyncNotifyFlag = 0; + retryCount = 0; + backoffRetryTime = 0; + WalError("Max Retransmission limit reached for Sync notification retry.\n"); + } } else { g_checkSyncNotifyRetry = 0; WalInfo("CMC is equal to 512, cloud and CPE are in sync\n"); - WalInfo("g_checkSyncNotifyRetry is set to 0\n"); - c = 3; + WalInfo("g_checkSyncNotifyRetry is set to 0\n"); + EnableSyncNotifyFlag = 1; + retryCount = 0; backoffRetryTime = 0; WalPrint("CMC is 512, reseting backoffRetryTime to initial value\n"); }