Browse code

dmq: removed params field from dmq_node_t

- used only for setting a flag
- duplicating a node caused issues with param field not being
duplicated, resulting in potential many free of same pointer, reported
by Sebastian Damm

Daniel-Constantin Mierla authored on 17/11/2015 21:51:01
Showing 3 changed files
... ...
@@ -185,20 +185,12 @@ dmq_node_t* build_dmq_node(str* uri, int shm) {
185 185
 	}
186 186
 	/* if any params found */
187 187
 	if(params) {
188
-		if(shm) {
189
-			if(shm_duplicate_params(&ret->params, params) < 0) {
190
-				LM_ERR("error duplicating params\n");
191
-				free_params(params);
192
-				goto error;
193
-			}
188
+		if(set_dmq_node_params(ret, params) < 0) {
194 189
 			free_params(params);
195
-		} else {
196
-			ret->params = params;
197
-		}
198
-		if(set_dmq_node_params(ret, ret->params) < 0) {
199 190
 			LM_ERR("error setting parameters\n");
200 191
 			goto error;
201 192
 		}
193
+		free_params(params);
202 194
 	} else {
203 195
 		LM_DBG("no dmqnode params found\n");		
204 196
 	}
... ...
@@ -248,12 +240,8 @@ dmq_node_t* find_dmq_node_uri2(str* uri)
248 248
 void destroy_dmq_node(dmq_node_t* node, int shm)
249 249
 {
250 250
 	if(shm) {
251
-		if (node->params!=NULL)
252
-			shm_free_params(node->params);
253 251
 		shm_free_node(node);
254 252
 	} else {
255
-		if (node->params!=NULL)
256
-			free_params(node->params);
257 253
 		pkg_free_node(node);
258 254
 	}
259 255
 }
... ...
@@ -43,7 +43,6 @@ typedef struct dmq_node {
43 43
 	str orig_uri; /* original uri string - e.g. sip:127.0.0.1:5060;passive=true */
44 44
 	struct sip_uri uri; /* parsed uri string */
45 45
 	struct ip_addr ip_address; /* resolved IP address */
46
-	param_t* params; /* uri parameters */
47 46
 	int status; /* reserved - maybe something like active,timeout,disabled */
48 47
 	int last_notification; /* last notificatino receied from the node */
49 48
 	struct dmq_node* next; /* pointer to the next struct dmq_node */
... ...
@@ -406,7 +406,7 @@ int extract_node_list(dmq_node_list_t* update_list, struct sip_msg* msg)
406 406
 			update_list->nodes = cur;
407 407
 			update_list->count++;
408 408
 			total_nodes++;
409
-		} else if (find->params && ret->status != find->status) {
409
+		} else if (find->uri.params.s && ret->status != find->status) {
410 410
 			LM_DBG("updating status on %.*s from %d to %d\n",
411 411
 				STR_FMT(&tmp_uri), ret->status, find->status);
412 412
 			ret->status = find->status;