Browse code

dmq: add branches when replicating to multiple nodes

- reported by Leonardo Arena

(cherry picked from commit ff114281fc2f523ed7bf87ea31448ce7327fdf93)

Charles Chance authored on 06/02/2015 10:59:35
Showing 1 changed files
... ...
@@ -24,6 +24,7 @@
24 24
 
25 25
 #include "dmq_funcs.h"
26 26
 #include "notification_peer.h"
27
+#include "../../dset.h"
27 28
 
28 29
 /**
29 30
  * @brief register a DMQ peer
... ...
@@ -385,6 +386,7 @@ int cfg_dmq_t_replicate(struct sip_msg* msg, char* s)
385 386
 	dmq_node_t* node;
386 387
 	struct socket_info* sock;
387 388
 	int i = 0;
389
+	int first = 1;
388 390
 
389 391
 	/* avoid loops - do not replicate if message has come from another node
390 392
 	 * (override if optional parameter is set)
... ...
@@ -413,10 +415,22 @@ int cfg_dmq_t_replicate(struct sip_msg* msg, char* s)
413 415
                         node = node->next;
414 416
 			continue;
415 417
 		}
418
+
419
+		if (!first) {
420
+			if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0, sock, 0, 0, 0, 0) == -1) {
421
+				LM_ERR("failed to append a branch\n");
422
+				node = node->next;
423
+				continue;
424
+			}
425
+		} else {
426
+			first = 0;
427
+		}
428
+
416 429
 		if(tmb.t_replicate(msg, &node->orig_uri) < 0) {
417 430
 			LM_ERR("error calling t_replicate\n");
418 431
 			goto error;
419 432
 		}
433
+
420 434
 		node = node->next;
421 435
 	}
422 436
 	lock_release(&node_list->lock);