Skip to content

Commit 7efbeca

Browse files
Merge pull request #4 from krishnangnair/webcfg-log
Webconfig Log checks and Improvements.
2 parents 18b00e3 + 5e7d822 commit 7efbeca

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

src/webcfg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ void *WebConfigMultipartTask(void *status)
8989
{
9090
if(forced_sync)
9191
{
92-
WebcfgInfo("Triggered Forced sync\n");
92+
WebcfgDebug("Triggered Forced sync\n");
9393
processWebconfgSync((int)Status);
94-
WebcfgInfo("reset forced_sync after sync\n");
94+
WebcfgDebug("reset forced_sync after sync\n");
9595
forced_sync = 0;
9696
setForceSync("", "", 0);
9797
}
@@ -125,7 +125,7 @@ void *WebConfigMultipartTask(void *status)
125125
if((ForceSyncDoc != NULL) && strlen(ForceSyncDoc)>0)
126126
{
127127
forced_sync = 1;
128-
WebcfgInfo("Received signal interrupt to Force Sync\n");
128+
WebcfgDebug("Received signal interrupt to Force Sync\n");
129129
WEBCFG_FREE(ForceSyncDoc);
130130
WEBCFG_FREE(ForceSyncTransID);
131131
}
@@ -261,7 +261,7 @@ int handlehttpResponse(long response_code, char *webConfigData, int retry_count,
261261
}
262262
else
263263
{
264-
WebcfgError("Failed to apply webConfigData\n");
264+
WebcfgError("Failed to apply root webConfigData received from server\n");
265265
return 1;
266266
}
267267
}

src/webcfg_db.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ WEBCFG_STATUS generateBlob()
144144

145145
if(webcfgdb_blob)
146146
{
147-
WebcfgInfo("Delete existing webcfgdb_blob.\n");
147+
WebcfgDebug("Delete existing webcfgdb_blob.\n");
148148
WEBCFG_FREE(webcfgdb_blob->data);
149149
WEBCFG_FREE(webcfgdb_blob);
150150
webcfgdb_blob = NULL;
151151
}
152-
WebcfgInfo("Generate new blob\n");
152+
WebcfgDebug("Generate new blob\n");
153153
if(webcfgdb_data != NULL || g_head != NULL)
154154
{
155155
webcfgdbBlobPackSize = webcfgdb_blob_pack(webcfgdb_data, g_head, &data);
@@ -423,7 +423,7 @@ WEBCFG_STATUS updateDBlist(char *docname, uint32_t version)
423423
if( strcmp(docname, webcfgdb->name) == 0)
424424
{
425425
webcfgdb->version = version;
426-
WebcfgInfo("webcfgdb %s is updated to version %lu\n", docname, (long)webcfgdb->version);
426+
WebcfgDebug("webcfgdb %s is updated to version %lu\n", docname, (long)webcfgdb->version);
427427
return WEBCFG_SUCCESS;
428428
}
429429
webcfgdb= webcfgdb->next;
@@ -474,7 +474,7 @@ WEBCFG_STATUS deleteFromTmpList(char* doc_name)
474474
WebcfgError("Invalid value for doc\n");
475475
return WEBCFG_FAILURE;
476476
}
477-
WebcfgInfo("doc to be deleted: %s\n", doc_name);
477+
WebcfgDebug("doc to be deleted: %s\n", doc_name);
478478

479479
prev_node = NULL;
480480
curr_node = g_head ;
@@ -824,8 +824,7 @@ char * base64blobencoder(char * blob_data, size_t blob_size )
824824
char* b64buffer = NULL;
825825
size_t encodeSize = -1;
826826
WebcfgDebug("Data is %s\n", blob_data);
827-
828-
WebcfgDebug("-----------Start of Base64 Encode ------------\n");
827+
WebcfgDebug("-----------Start of Base64 Encode ------------\n");
829828
encodeSize = b64_get_encoded_buffer_size(blob_size);
830829
WebcfgDebug("encodeSize is %zu\n", encodeSize);
831830
b64buffer = malloc(encodeSize + 1);

src/webcfg_multipart.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,22 +352,18 @@ WEBCFG_STATUS parseMultipartDocument(void *config_data, char *ct , size_t data_s
352352
}
353353
if(0 == memcmp(ptr_lb, line_boundary, strlen(line_boundary)))
354354
{
355-
ptr_lb = ptr_lb+(strlen(line_boundary));
355+
ptr_lb = ptr_lb+(strlen(line_boundary))-1;
356356
num_of_parts = 1;
357357
while(0 != num_of_parts % 2)
358358
{
359-
ptr_lb = memchr(ptr_lb, '\n', data_size - (ptr_lb - str_body));
360-
// printf("printing newline: %ld\n",ptr_lb-str_body);
361359
ptr_lb1 = memchr(ptr_lb+1, '\n', data_size - (ptr_lb - str_body));
362-
// printf("printing newline2: %ld\n",ptr_lb1-str_body);
363360
if(0 != memcmp(ptr_lb1-1, "\r",1 )){
364361
ptr_lb1 = memchr(ptr_lb1+1, '\n', data_size - (ptr_lb - str_body));
365362
}
366363
index2 = ptr_lb1-str_body;
367364
index1 = ptr_lb-str_body;
368365
parse_multipart(str_body+index1+1,index2 - index1 - 2, &mp->entries[count]);
369366
ptr_lb++;
370-
371367
if(0 == memcmp(ptr_lb, last_line_boundary, strlen(last_line_boundary)))
372368
{
373369
WebcfgDebug("last line boundary inside \n");
@@ -379,7 +375,8 @@ WEBCFG_STATUS parseMultipartDocument(void *config_data, char *ct , size_t data_s
379375
num_of_parts++;
380376
count++;
381377
}
382-
}
378+
ptr_lb = memchr(ptr_lb, '\n', data_size - (ptr_lb - str_body));
379+
}
383380
}
384381
else
385382
{
@@ -397,7 +394,7 @@ WEBCFG_STATUS parseMultipartDocument(void *config_data, char *ct , size_t data_s
397394
}
398395
else
399396
{
400-
WebcfgError("processMsgpackSubdoc failed\n");
397+
WebcfgError("processMsgpackSubdoc failed,as all the docs are not applied\n");
401398
}
402399
return WEBCFG_FAILURE;
403400
}
@@ -482,7 +479,7 @@ WEBCFG_STATUS processMsgpackSubdoc(multipart_t *mp, char *transaction_id)
482479
reqParam[i].type = pm->entries[i].type;
483480
}
484481
}
485-
WebcfgInfo("Request:> param[%d].name = %s\n",i,reqParam[i].name);
482+
WebcfgInfo("Request:> param[%d].name = %s, type = %d\n",i,reqParam[i].name,reqParam[i].type);
486483
WebcfgDebug("Request:> param[%d].value = %s\n",i,reqParam[i].value);
487484
WebcfgDebug("Request:> param[%d].type = %d\n",i,reqParam[i].type);
488485
}
@@ -617,7 +614,7 @@ WEBCFG_STATUS processMsgpackSubdoc(multipart_t *mp, char *transaction_id)
617614
j--;
618615
temp1 = temp1->next;
619616
}
620-
WebcfgInfo("addNewDocEntry\n");
617+
WebcfgDebug("addNewDocEntry\n");
621618
addNewDocEntry(get_successDocCount());
622619
}
623620

@@ -1243,8 +1240,18 @@ void multipart_destroy( multipart_t *m )
12431240

12441241
void parse_multipart(char *ptr, int no_of_bytes, multipartdocs_t *m)
12451242
{
1243+
char *Content_type = NULL;
12461244
/*for storing respective values */
1247-
if(0 == strncasecmp(ptr,"Namespace",strlen("Namespace")))
1245+
if(0 == strncmp(ptr,"Content-type: ",strlen("Content-type")))
1246+
{
1247+
Content_type = strndup(ptr+(strlen("Content-type: ")),no_of_bytes-((strlen("Content-type: "))));
1248+
if(strncmp(Content_type, "application/msgpack",strlen("application/msgpack")) !=0)
1249+
{
1250+
WebcfgError("Content-type not msgpack: %s", Content_type);
1251+
}
1252+
WEBCFG_FREE(Content_type);
1253+
}
1254+
else if(0 == strncasecmp(ptr,"Namespace",strlen("Namespace")))
12481255
{
12491256
m->name_space = strndup(ptr+(strlen("Namespace: ")),no_of_bytes-((strlen("Namespace: "))));
12501257
}

0 commit comments

Comments
 (0)