Skip to content

Commit

Permalink
Force sync got stuck with in progress error when both force sync and …
Browse files Browse the repository at this point in the history
…maintenance sync happened together
  • Loading branch information
vasuki01 committed Jun 13, 2024
1 parent d46b2b2 commit 56dc57b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
43 changes: 21 additions & 22 deletions src/webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void *WebConfigMultipartTask(void *status)
clock_gettime(CLOCK_REALTIME, &ts);

retry_flag = get_doc_fail();
WebcfgDebug("The retry flag value is %d\n", retry_flag);
WebcfgInfo("The retry flag value is %d\n", retry_flag);

if ( retry_flag == 0)
{
Expand Down Expand Up @@ -291,7 +291,7 @@ void *WebConfigMultipartTask(void *status)
}
else if(retry_flag == 1 || maintenance_doc_sync == 1)
{
WebcfgDebug("B4 sync_condition pthread_cond_timedwait\n");
WebcfgInfo("B4 sync_condition pthread_cond_timedwait\n");
set_maintenanceSync(false);
WebcfgInfo("reset maintenanceSync to false\n");
rv = pthread_cond_timedwait(&sync_condition, &sync_mutex, &ts);
Expand All @@ -302,26 +302,7 @@ void *WebConfigMultipartTask(void *status)
{
rv = pthread_cond_wait(&sync_condition, &sync_mutex);
}

if(rv == ETIMEDOUT && !g_shutdown)
{
if(get_doc_fail() == 1)
{
set_doc_fail(0);
set_retry_timer(900);
set_global_retry_timestamp(0);
failedDocsRetry();
WebcfgDebug("After the failedDocsRetry\n");
}
else
{
time(&t);
wait_flag = 0;
maintenance_count = 0;
WebcfgDebug("Supplementary Sync Interval %d sec and syncing at %s\n",value,ctime(&t));
}
}
else if(!rv && !g_shutdown)
if(!rv && !g_shutdown)
{
//webcfg_forcedsync_needed is set initially whenever force sync SET is detected internally & webcfg_forcedsync_started is set when actual sync is started once previous sync is completed.
if(get_global_webcfg_forcedsync_needed())
Expand Down Expand Up @@ -367,6 +348,24 @@ void *WebConfigMultipartTask(void *status)

WebcfgDebug("forced_sync is %d\n", forced_sync);
}
else if(rv == ETIMEDOUT && !g_shutdown)
{
if(get_doc_fail() == 1)
{
set_doc_fail(0);
set_retry_timer(900);
set_global_retry_timestamp(0);
failedDocsRetry();
WebcfgDebug("After the failedDocsRetry\n");
}
else
{
time(&t);
wait_flag = 0;
maintenance_count = 0;
WebcfgInfo("Supplementary Sync Interval %d sec and syncing at %s\n",value,ctime(&t));
}
}
else if(g_shutdown)
{
WebcfgInfo("Received signal interrupt to RFC disable. g_shutdown is %d, proceeding to kill webconfig thread\n", g_shutdown);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void test_POSTNONE()

derive_root_doc_version_string(&root_str, &root_version, http_status);
CU_ASSERT_FATAL( NULL != root_str );
CU_ASSERT_STRING_EQUAL( "NONE-REBOOT", root_str );
CU_ASSERT_STRING_EQUAL( "POST-NONE", root_str );
fp = fopen("/tmp/webconfig_db.bin","rb");
if(fp !=NULL)
{
Expand Down

0 comments on commit 56dc57b

Please sign in to comment.