<div dir="ltr">Thank you Daniel for the suggestion. I realized that I misunderstood the meaning of nr_branches. My intention was to use it as a "starting point" to check only the newly created branches in the destination set. I will change it according to your suggestion and also remove the history if you agree.<div><br></div><div>Thank you,</div><div><br></div><div>Federico</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 4, 2015 at 3:27 PM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    It is not a big problem, just wanted to underline it to be aware of.
    And it would be good to be removed, indeed.<br>
    <br>
    As I looked at the code in the file with this occasion, if you want
    to go through all outgoing branches in the destination set, then you
    need to do:<br>
    <br>
    init_branch_iterator();<br>
    <br>
    instead of:<br>
    <br>
    set_branch_iterator(nr_branches-1);<br>
    <br>
    That will look at all next hops that are already in destination set.<br>
    <br>
    Assuming that you mainly use this function when you get a new
    registration and have one new outgoing branch, then nr_branches-1
    can result to be 0. However, if for what so ever reason you get more
    branches, then you will use only one with existing code. As I got it
    from the code, you check if the destination is already used, so just
    going again from branch 0 in destination set looks like what you
    wanted to do. Maybe I am wrong ...<br>
    <br>
    Cheers,<br>
    Daniel<div><div class="h5"><br>
    <br>
    <div>On 04/09/15 15:21, Federico Cabiddu
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">I'm sorry,
        <div>I didn't see it with git difftool before committing. Do you
          want that I clean the file?</div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div><br>
        </div>
        <div>Federico</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Sep 4, 2015 at 3:18 PM,
          Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank"></a><a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
            <br>
            you re-introduced the history at the top of the file, which
            was removed<br>
            from tm module and going to be removed from everywhere in
            the code, as<br>
            most of it is irrelevant. The changes are better tracked via
            git now,<br>
            with the commit message and git diff/blame being very handy.<br>
            <br>
            Cheers,<br>
            Daniel<br>
            <div>
              <div><br>
                On 04/09/15 15:13, Federico Cabiddu wrote:<br>
                > Module: kamailio<br>
                > Branch: master<br>
                > Commit: 27bed654dcc4e9dd543a7f2f92e2174478bf7f26<br>
                > URL: <a href="https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26" rel="noreferrer" target="_blank">https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26</a><br>
                ><br>
                > Author: Federico Cabiddu <<a href="mailto:federico.cabiddu@gmail.com" target="_blank"></a><a href="mailto:federico.cabiddu@gmail.com" target="_blank">federico.cabiddu@gmail.com</a>><br>
                > Committer: Federico Cabiddu <<a href="mailto:federico.cabiddu@gmail.com" target="_blank"></a><a href="mailto:federico.cabiddu@gmail.com" target="_blank">federico.cabiddu@gmail.com</a>><br>
                > Date: 2015-09-04T15:12:29+02:00<br>
                ><br>
                > tm: check all the outgoing branches when appending
                a new branch<br>
                ><br>
                > ---<br>
                ><br>
                > Modified: modules/tm/t_append_branches.c<br>
                ><br>
                > ---<br>
                ><br>
                > Diff:  <a href="https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26.diff" rel="noreferrer" target="_blank">https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26.diff</a><br>
                > Patch: <a href="https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26.patch" rel="noreferrer" target="_blank">https://github.com/kamailio/kamailio/commit/27bed654dcc4e9dd543a7f2f92e2174478bf7f26.patch</a><br>
                ><br>
                > ---<br>
                ><br>
                > diff --git a/modules/tm/t_append_branches.c
                b/modules/tm/t_append_branches.c<br>
                > index 8060021..f16c672 100644<br>
                > --- a/modules/tm/t_append_branches.c<br>
                > +++ b/modules/tm/t_append_branches.c<br>
                > @@ -23,6 +23,9 @@<br>
                >   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
                OF THE USE OF THIS SOFTWARE,<br>
                >   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
                DAMAGE.<br>
                >   *<br>
                > + * History:<br>
                > + * -------<br>
                > + *  2014-09-09  first release of t_append_branches<br>
                >   *<br>
                >   */<br>
                ><br>
                > @@ -106,8 +109,6 @@ int t_append_branches(void) {<br>
                >             
                 set_branch_route(t->on_branch_delayed);<br>
                >       }<br>
                ><br>
                > -     outgoings = t->nr_of_outgoings;<br>
                > -<br>
                >       /* not really sure that the following is
                needed */<br>
                ><br>
                >       set_branch_iterator(nr_branches-1);<br>
                > @@ -116,7 +117,7 @@ int t_append_branches(void) {<br>
                >                                                   
                                           &bflags, &si,
                &ruid, &instance, &location_ua))) {<br>
                >               LM_DBG("Current uri
                %.*s\n",current_uri.len, current_uri.s);<br>
                ><br>
                > -             for (i=0; i<=nr_branches; i++) {<br>
                > +             for (i=0; i<outgoings; i++) {<br>
                >                       if (t->uac[i].ruid.len ==
                ruid.len<br>
                >                                       &&
                !memcmp(t->uac[i].ruid.s, ruid.s, ruid.len)) {<br>
                >                               LM_DBG("branch
                already added [%.*s]\n", ruid.len, ruid.s);<br>
                > @@ -133,6 +134,8 @@ int t_append_branches(void) {<br>
                >                                       &path, 0,
                si, orig_msg->fwd_send_flags,<br>
                >                                     
                 orig_msg->rcv.proto,
                (dst_uri.len)?-1:UAC_SKIP_BR_DST_F, &instance,<br>
                >                                       &ruid,
                &location_ua);<br>
                > +<br>
                > +             LM_DBG("added branch [%.*s] with ruid
                [%.*s]\n", current_uri.len, current_uri.s, ruid.len,
                ruid.s);<br>
                ><br>
                >               /* test if cancel was received
                meanwhile */<br>
                >               if (t->flags & T_CANCELED)
                goto canceled;<br>
                ><br>
                ><br>
                > _______________________________________________<br>
                > sr-dev mailing list<br>
                > <a href="mailto:sr-dev@lists.sip-router.org" target="_blank">sr-dev@lists.sip-router.org</a><br>
                > <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
                <br>
              </div>
            </div>
            <span><font color="#888888">--<br>
                Daniel-Constantin Mierla<br>
                <a href="http://twitter.com/#%21/miconda" rel="noreferrer" target="_blank">http://twitter.com/#!/miconda</a>
                - <a href="http://www.linkedin.com/in/miconda" rel="noreferrer" target="_blank">http://www.linkedin.com/in/miconda</a><br>
                Book: SIP Routing With Kamailio - <a href="http://www.asipto.com" rel="noreferrer" target="_blank"></a><a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
                <br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre cols="72">-- 
Daniel-Constantin Mierla
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Book: SIP Routing With Kamailio - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a></pre>
  </div></div></div>

</blockquote></div><br></div>