[sr-dev] Append branches in module

Charles Chance charles.chance at sipcentric.com
Wed Feb 4 13:29:35 CET 2015


Hi All,

Can anyone confirm, is this safe? Primary use case is replication of
REGISTER after local save().


diff --git a/modules/dmq/dmq_funcs.c b/modules/dmq/dmq_funcs.c
index b31deba..a3611e8 100644
--- a/modules/dmq/dmq_funcs.c
+++ b/modules/dmq/dmq_funcs.c
@@ -24,6 +24,7 @@

 #include "dmq_funcs.h"
 #include "notification_peer.h"
+#include "../../dset.h"

 /**
  * @brief register a DMQ peer
@@ -385,6 +386,7 @@ int cfg_dmq_t_replicate(struct sip_msg* msg, char* s)
        dmq_node_t* node;
        struct socket_info* sock;
        int i = 0;
+       int first = 1;

        /* avoid loops - do not replicate if message has come from another
node
         * (override if optional parameter is set)
@@ -413,10 +415,22 @@ int cfg_dmq_t_replicate(struct sip_msg* msg, char* s)
                        node = node->next;
                        continue;
                }
+
+               if (!first) {
+                       if (append_branch(msg, 0, 0, 0, Q_UNSPECIFIED, 0,
sock, 0, 0, 0, 0) == -1) {
+                               LM_ERR("failed to append a branch\n");
+                               node = node->next;
+                               continue;
+                       }
+               } else {
+                       first = 0;
+               }
+
                if(tmb.t_replicate(msg, &node->orig_uri) < 0) {
                        LM_ERR("error calling t_replicate\n");
                        goto error;
                }
+
                node = node->next;
        }
        lock_release(&node_list->lock);


Many thanks,

Charles

-- 
www.sipcentric.com

Follow us on twitter @sipcentric <http://twitter.com/sipcentric>

Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered 
office: Faraday Wharf, Innovation Birmingham Campus, Holt Street, 
Birmingham Science Park, Birmingham B7 4BB.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20150204/8f2d72b2/attachment.html>


More information about the sr-dev mailing list