Skip to content

Commit

Permalink
Reduce webpa sync notification retry attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
nlrcomcast committed Dec 12, 2024
1 parent 24a1969 commit 2322622
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions source/broadband/include/webpa_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
51 changes: 26 additions & 25 deletions source/broadband/webpa_notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 2322622

Please sign in to comment.