Browse code

dmq: fixes for changes in the 678f9c6ad8a8118741a921fcc01f9b23b5702c6e

- init the next field to first notification address str_list_t item
- init local variables to avoid compile warnings on using garbage value
- while condition on server_list instead of address of its ->s field
(which always not null)
- do not iterate using global dmq_notification_address_list variable, it
shifts it till becomes NULL

Daniel-Constantin Mierla authored on 05/04/2021 09:37:06
Showing 2 changed files
... ...
@@ -387,6 +387,7 @@ static int dmq_add_notification_address(modparam_t type, void * val)
387 387
 		}
388 388
 		dmq_tmp_list = dmq_notification_address_list;
389 389
 		dmq_tmp_list->s = tmp_str;
390
+		dmq_tmp_list->next = NULL;
390 391
 	} else {
391 392
 		dmq_tmp_list = append_str_list(tmp_str.s, tmp_str.len, &dmq_tmp_list, &total_list);
392 393
 		if (dmq_tmp_list == NULL) {
... ...
@@ -284,7 +284,7 @@ dmq_node_t *add_server_and_notify(str_list_t *server_list)
284 284
 {
285 285
 	char puri_data[MAXDMQHOSTS * (MAXDMQURILEN + 1)];
286 286
 	char *puri_list[MAXDMQHOSTS];
287
-	dmq_node_t *pfirst, *pnode;
287
+	dmq_node_t *pfirst = NULL, *pnode = NULL;
288 288
 	int host_cnt, index;
289 289
 	sip_uri_t puri[1];
290 290
 	str pstr[1];
... ...
@@ -296,7 +296,7 @@ dmq_node_t *add_server_and_notify(str_list_t *server_list)
296 296
 	**********/
297 297
 
298 298
 	if(!dmq_multi_notify) {
299
-		while (&server_list->s != NULL) {
299
+		while (server_list != NULL) {
300 300
 			LM_DBG("adding notification node %.*s\n",
301 301
 				server_list->s.len, server_list->s.s);
302 302
 			pfirst = add_dmq_node(dmq_node_list, &server_list->s);
... ...
@@ -592,6 +592,7 @@ int notification_resp_callback_f(
592 592
 {
593 593
 	int ret;
594 594
 	int nodes_recv;
595
+	str_list_t *slp;
595 596
 
596 597
 	LM_DBG("notification_callback_f triggered [%p %d %p]\n", msg, code, param);
597 598
 	if(code == 200) {
... ...
@@ -605,15 +606,16 @@ int notification_resp_callback_f(
605 606
 		}
606 607
 	} else if(code == 408) {
607 608
 		/* TODO this probably do not work for dmq_multi_notify */
608
-		while (&dmq_notification_address_list->s != NULL) {
609
-			if(STR_EQ(node->orig_uri, dmq_notification_address_list->s)) {
609
+		slp = dmq_notification_address_list;
610
+		while (slp != NULL) {
611
+			if(STR_EQ(node->orig_uri, slp->s)) {
610 612
 				LM_ERR("not deleting notification peer [%.*s]\n",
611
-					STR_FMT(&dmq_notification_address_list->s));
613
+					STR_FMT(&slp->s));
612 614
 				update_dmq_node_status(dmq_node_list, node, DMQ_NODE_PENDING);
613 615
 				return 0;
614 616
 			}
615
-			dmq_notification_address_list = dmq_notification_address_list->next;
616
-               }
617
+			slp = slp->next;
618
+		}
617 619
 		if (node->status == DMQ_NODE_DISABLED) {
618 620
 			/* deleting node - the server did not respond */
619 621
 			LM_ERR("deleting server node %.*s because of failed request\n",