Skip to content

Commit

Permalink
resync support for primary and supplementary
Browse files Browse the repository at this point in the history
  • Loading branch information
nlrcomcast committed Jan 9, 2025
1 parent 0b7bc1f commit 18f3240
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ExternalProject_Add(msgpack
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
-DMSGPACK_BUILD_TESTS=OFF
)
add_library(libmsgpack STATIC SHARED IMPORTED)
add_dependencies(libmsgpack msgpack)
Expand Down
11 changes: 8 additions & 3 deletions src/webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "webcfg_event.h"
#include "webcfg_blob.h"
#include "webcfg_timer.h"
#include "webcfg_rbus.h"

#ifdef FEATURE_SUPPORT_MQTTCM
#include "webcfg_mqtt.h"
Expand Down Expand Up @@ -192,6 +193,7 @@ void *WebConfigMultipartTask(void *status)
{
WEBCFG_FREE(syncDoc);
}
setForceSyncTransID("");
setForceSync("", "", 0);
set_global_supplementarySync(0);
if(get_global_webcfg_forcedsync_started())
Expand All @@ -215,6 +217,7 @@ void *WebConfigMultipartTask(void *status)
char *ForceSyncDoc = NULL;
char* ForceSyncTransID = NULL;
getForceSync(&ForceSyncDoc, &ForceSyncTransID);
setForceSyncTransID(ForceSyncTransID);

Check warning on line 220 in src/webcfg.c

View check run for this annotation

Codecov / codecov/patch

src/webcfg.c#L220

Added line #L220 was not covered by tests
if((ForceSyncDoc == NULL) && (ForceSyncTransID == NULL) && (!forced_sync) && (!get_bootSync()))
{
WebcfgInfo("release success docs at every maintenance window\n");
Expand Down Expand Up @@ -339,12 +342,12 @@ void *WebConfigMultipartTask(void *status)

// Identify ForceSync based on docname
getForceSync(&ForceSyncDoc, &ForceSyncTransID);
setForceSyncTransID(ForceSyncTransID);
if(ForceSyncDoc !=NULL && ForceSyncTransID !=NULL)
{
WebcfgInfo("ForceSyncDoc %s ForceSyncTransID. %s\n", ForceSyncDoc, ForceSyncTransID);
}
if(ForceSyncTransID !=NULL)
{

if((ForceSyncDoc != NULL) && strlen(ForceSyncDoc)>0)
{
forced_sync = 1;
Expand All @@ -367,7 +370,6 @@ void *WebConfigMultipartTask(void *status)
WebcfgError("ForceSyncDoc is NULL\n");
WEBCFG_FREE(ForceSyncTransID);
}
}

WebcfgDebug("forced_sync is %d\n", forced_sync);
}
Expand Down Expand Up @@ -463,6 +465,9 @@ void *WebConfigMultipartTask(void *status)
WebcfgDebug("supplementary_destroy\n");
delete_supplementary_list();

WebcfgDebug("ForceSyncMsgQueue_destroy\n");
deleteForceSyncMsgQueue();

WebcfgInfo("B4 pthread_exit\n");
g_mpthreadId = NULL;
pthread_exit(0);
Expand Down
29 changes: 13 additions & 16 deletions src/webcfg_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static char g_deviceWanMac[64]={'\0'};
static char *supportedVersion_header=NULL;
static char *supportedDocs_header=NULL;
static char *supplementaryDocs_header=NULL;
static char g_ForceSyncTransID[128]={'\0'};
#endif
char g_RebootReason[64]={'\0'};
static char g_transID[64]={'\0'};
Expand Down Expand Up @@ -171,7 +172,6 @@ char * get_global_interface(void)
/* Function Prototypes */
/*----------------------------------------------------------------------------*/
void addToDBList(webconfig_db_data_t *webcfgdb);
char* generate_trans_uuid();
void loadInitURLFromFile(char **url);

#ifdef FEATURE_SUPPORT_AKER
Expand Down Expand Up @@ -1557,8 +1557,6 @@ void createCurlHeader( struct curl_slist *list, struct curl_slist **header_list,
char *transaction_uuid = NULL;
char version[512]={'\0'};
char docList[512]={'\0'};
char* syncTransID = NULL;
char* ForceSyncDoc = NULL;
size_t supported_doc_size = 0;
size_t supported_version_size = 0;
size_t supplementary_docs_size = 0;
Expand Down Expand Up @@ -1795,20 +1793,10 @@ void createCurlHeader( struct curl_slist *list, struct curl_slist **header_list,
WebcfgDebug("Failed to get systemReadyTime\n");
}

getForceSync(&ForceSyncDoc, &syncTransID);

if(syncTransID !=NULL)
if((g_ForceSyncTransID !=NULL) && (strlen(g_ForceSyncTransID)>0))
{
if(ForceSyncDoc !=NULL)
{
if (strlen(syncTransID)>0)
{
WebcfgInfo("updating transaction_uuid with force syncTransID\n");
transaction_uuid = strdup(syncTransID);
}
WEBCFG_FREE(ForceSyncDoc);
}
WEBCFG_FREE(syncTransID);
WebcfgInfo("updating transaction_uuid with force g_ForceSyncTransID\n");
transaction_uuid = strdup(g_ForceSyncTransID);
}

if(transaction_uuid == NULL)
Expand Down Expand Up @@ -2589,3 +2577,12 @@ int get_multipartdoc_count()
}
return count;
}

void setForceSyncTransID(char *ForceSyncTransID)
{
memset(g_ForceSyncTransID, 0, sizeof(g_ForceSyncTransID));
if(ForceSyncTransID!=NULL)
{
webcfgStrncpy( g_ForceSyncTransID, ForceSyncTransID, sizeof(g_ForceSyncTransID));
}
}
2 changes: 2 additions & 0 deletions src/webcfg_multipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void get_webCfg_interface(char **interface);
size_t headr_callback(char *buffer, size_t size, size_t nitems, void* data);
size_t writer_callback_fn(void *buffer, size_t size, size_t nmemb, void *datain);
WEBCFG_STATUS processMsgpackSubdoc(char *transaction_id);
void setForceSyncTransID(char *ForceSyncTransID);
char* generate_trans_uuid();
#ifdef WAN_FAILOVER_SUPPORTED
void set_global_interface(char * value);
char * get_global_interface(void);
Expand Down
Loading

0 comments on commit 18f3240

Please sign in to comment.