<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>as I see it in the issue tracker, with revert_uri() the $ru is
      not added to the destinations list, only the two appended branches
      appear in the logs. So that is no longer an issue, right? Only the
      reverse ordering?</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 19.08.20 18:43, Cindy Leung wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CA+J76DiOCToU79XJ0_fNNEb3Njb9TJ=O-2J5-djD1fxPn0zMSQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Daniel,
        <div><br>
        </div>
        <div>Thanks for the suggestion.  I'm not modifying the R-URI in
          any way but tested with revert_uri() regardless.  The behavior
          is the same.  I'll open a ticket.  Thanks.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Cindy</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Aug 19, 2020 at 10:18
          AM Daniel-Constantin Mierla <<a
            href="mailto:miconda@gmail.com" moz-do-not-send="true">miconda@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>Looking a bit at the node, I see that the r-uri branch is
              ignored if not changed at all. So if you updated r-uri in
              the config, then it will be kept. But the same behaviour
              seems to be in 5.3. Maybe in the new config you do
              operations over $ru or use some functions changing it.</p>
            <p>You can try to do revert_uri() before t_load_contacts(0).</p>
            <p>Cheers,<br>
              Daniel<br>
            </p>
            <div>On 19.08.20 16:12, Daniel-Constantin Mierla wrote:<br>
            </div>
            <blockquote type="cite">
              <p>Hello,</p>
              <div>On 18.08.20 08:05, Cindy Leung wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">Hello all,
                  <div><br>
                  </div>
                  <div>Just started using v5.4.0 on our system and I
                    noticed a change in behavior when doing the
                    append_branch, t_load_contacts, and t_next_contacts
                    combo.  Previously using v5.3.4 and it appears to be
                    fine.</div>
                  <div><br>
                  </div>
                  <div>Here's the call scenario: Kamailio receives a
                    call to <a moz-do-not-send="true">sip:1001@carrierB</a>. 
                    Kamailio sees carrierB and appends 2 contacts: <a
                      href="http://gateway1.carrierB.com"
                      target="_blank" moz-do-not-send="true">gateway1.carrierB.com</a>;q=0.3
                    and <a href="http://gateway2.carrierB.com"
                      target="_blank" moz-do-not-send="true">gateway2.carrierB.com</a>;q=0.2. 
                    After t_load_branches(0),</div>
                </div>
              </blockquote>
              <p>first, I am not finding the t_load_branches() function,
                is it supposed to be t_load_contacts()?</p>
              <p>The, supposing it was the later, afaik, the load
                contacts was putting the branches in internal xavps, not
                pushing to the r-uri. The append_branch() was not
                changing the first branch (the r-uri) but adding extra.
                So if you have the invite coming in to <a
                  href="mailto:u1@s.com" target="_blank"
                  moz-do-not-send="true">u1@s.com</a> and do
                append_branch(<a href="mailto:u2@s.com" target="_blank"
                  moz-do-not-send="true">u2@s.com</a>) and
                append_branch(<a href="mailto:u3@s.com" target="_blank"
                  moz-do-not-send="true">u3@s.com</a>), then it will be
                3 branches that will go out in case of parallel forking.</p>
              <p>With t_load_contacts() and t_next_contacts(), these 3
                branches should be prepared to do serial forking.</p>
              <p>Now, I haven't really used these functions myself to
                comment more, it is based on what append_branch() is
                doing: adding extra branches and keeping the first
                branch (r-uri) untouched.<br>
              </p>
              <p>But if you found a different behaviour than expected,
                open a bug on issue tracker and we can refer the
                developer of commit
                1399714fbba63732f94eb8034dabb1e565ca832a (which added
                proportional load) to review it.</p>
              <p>Cheers,<br>
                Daniel<br>
              </p>
              <blockquote type="cite">
                <div dir="ltr">
                  <div> I expect to see $rd to be changed to <a
                      href="http://gateway1.carrierB.com"
                      target="_blank" moz-do-not-send="true">gateway1.carrierB.com</a>,
                    but it's not.</div>
                  <div><br>
                  </div>
                  <div>This is the piece of config I'm trying to debug:</div>
                  <div>        <font face="monospace">xlog ("=== branch
                      0: $(branch(uri)[0]), $(branch(q)[0])\n");<br>
                          xlog ("=== branch 1: $(branch(uri)[1]),
                      $(branch(q)[1])\n");<br>
                          t_load_contacts(0);<br>
                          while (t_next_contacts()) {<br>
                              xlog ("=== rd = $rd\n");<br>
                          }</font><br>
                  </div>
                  <div><br>
                  </div>
                  <div>This is the log I get.  It appears to use the
                    backup contact first.</div>
                  <div><font face="monospace">ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      === branch 0: <a
                        href="mailto:sip%3A1001@gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway2.carrierB.com</a>;transport=udp,
                      200<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      === branch 1: <a
                        href="mailto:sip%3A1001@gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway1.carrierB.com</a>;transport=tcp,
                      300<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      tm [t_serial.c:522]: t_load_contacts():
                      load_contact mode selected: 0<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      tm [t_serial.c:340]: ki_t_load_contacts_mode():
                      nr_branches is 2<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f983cb66608<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      tm [t_serial.c:890]: ki_t_next_contacts():
                      Appending branch <a
                        href="mailto:uri-%27sip%3A1001@gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">uri-'sip:1001@gateway1.carrierB.com</a>;transport=tcp'
                      dst-'' path-'' inst-'' ruid-'' location_ua-''<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f983cb66350<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      === rd = carrierB<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f983cb66078<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      === rd = <a href="http://gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">gateway2.carrierB.com</a><br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818053427-1-23@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818053427-1-23@172.18.1.21</a>:
                      tm [t_serial.c:627]: ki_t_next_contacts(): no
                      contacts in contacts_avp - we are done!</font><br>
                  </div>
                  <div><font face="monospace"><br>
                    </font></div>
                  <div><font face="arial, sans-serif">t_load_contacts(1)
                      works a little better.  But we don't need the
                      probability feature.</font></div>
                  <div><font face="monospace">ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      === branch 0: <a
                        href="mailto:sip%3A1001@gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway2.carrierB.com</a>;transport=udp,
                      200<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      === branch 1: <a
                        href="mailto:sip%3A1001@gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway1.carrierB.com</a>;transport=tcp,
                      300<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:522]: t_load_contacts():
                      load_contact mode selected: 1<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:340]: ki_t_load_contacts_mode():
                      nr_branches is 2<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:280]:
                      t_load_contacts_proportional(): proportionally
                      selected contact with uri: <a
                        href="mailto:sip%3A1001@gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway1.carrierB.com</a>;transport=tcp
                      (q: 300, random: 287, q_index: 500, q_total: 500)<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:280]:
                      t_load_contacts_proportional(): proportionally
                      selected contact with uri: <a
                        href="mailto:sip%3A1001@gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway2.carrierB.com</a>;transport=udp
                      (q: 200, random: 157, q_index: 200, q_total: 200)<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:303]:
                      t_load_contacts_proportional(): proportionally
                      added backup contact with uri: <a
                        moz-do-not-send="true">sip:1001@carrierB</a>
                      SIP/2.0#015#012Via: SIP/2.0/UDP
                      172.18.1.21:5060;branch=z9hG4bK-21-1-0 blah blah
                      blah (q: -1)<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f6e457ec078<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      === rd = <a href="http://gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">gateway1.carrierB.com</a><br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f6e457ec350<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      === rd = <a href="http://gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">gateway2.carrierB.com</a><br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:539]:
                      xavp_destroy_list(): destroying xavp list
                      0x7f6e457ec608<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      === rd = carrierB<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818054736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818054736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:627]: ki_t_next_contacts(): no
                      contacts in contacts_avp - we are done!</font><font
                      face="arial, sans-serif"><br>
                    </font></div>
                  <div><font face="arial, sans-serif"><br>
                    </font></div>
                  <div><font face="arial, sans-serif">As a comparison,
                      this is what we've been getting in 5.3.4</font></div>
                  <div><font face="monospace">ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      === branch 0: <a
                        href="mailto:sip%3A1001@gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway2.carrierB.com</a>;transport=udp,
                      200<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      === branch 1: <a
                        href="mailto:sip%3A1001@gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">sip:1001@gateway1.carrierB.com</a>;transport=tcp,
                      300<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:191]: ki_t_load_contacts():
                      nr_branches is 2<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:529]:
                      xavp_destroy_list(): destroying xavp list
                      0x7fe13146a680<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      === rd = <a href="http://gateway1.carrierB.com"
                        target="_blank" moz-do-not-send="true">gateway1.carrierB.com</a><br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:529]:
                      xavp_destroy_list(): destroying xavp list
                      0x7fe13146a3a8<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      === rd = <a href="http://gateway2.carrierB.com"
                        target="_blank" moz-do-not-send="true">gateway2.carrierB.com</a><br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      <core> [core/xavp.c:529]:
                      xavp_destroy_list(): destroying xavp list
                      0x7fe13146a0d0<br>
                      ERROR: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      === rd = carrierB<br>
                      DEBUG: IBG_LOG: <a
                        href="mailto:sipp-ci1-20200818055736-1-21@172.18.1.21"
                        target="_blank" moz-do-not-send="true">sipp-ci1-20200818055736-1-21@172.18.1.21</a>:
                      tm [t_serial.c:460]: ki_t_next_contacts(): no
                      contacts in contacts_avp - we are done!</font><font
                      face="arial, sans-serif"><br>
                    </font></div>
                  <div><span style="font-family:arial,sans-serif"><br>
                    </span></div>
                  <div><span style="font-family:arial,sans-serif">Is
                      there anything else that's been changed in branch
                      building that we should pay attention to?  Thanks.</span><br>
                  </div>
                  <div><span style="font-family:arial,sans-serif"><br>
                    </span></div>
                  <div><span style="font-family:arial,sans-serif"><br>
                    </span></div>
                  <div><span style="font-family:arial,sans-serif"><br>
                    </span></div>
                  <div><span style="font-family:arial,sans-serif">Cindy</span></div>
                  <div><font face="arial, sans-serif"><br>
                    </font></div>
                </div>
                <br>
                <fieldset></fieldset>
                <pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a href="mailto:sr-users@lists.kamailio.org" target="_blank" moz-do-not-send="true">sr-users@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
              </blockquote>
              <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank" moz-do-not-send="true">https://www.paypal.me/dcmierla</a></pre>
            </blockquote>
            <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank" moz-do-not-send="true">https://www.paypal.me/dcmierla</a></pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>