<div dir="ltr">Hi Razvan,<div><br></div><div>I have some news.</div><div><br></div><div>It happens for the following scenario:</div><div><br></div><div>1. For first branch, the branch route is executed therefore I can see the branch AVPs are created by our module.</div><div>2. The first branch fails and we do a second attempt to a different destination. So a second branch is created, the branch route is executed and new branch AVPs are created. However, unlike the first branch, we decide to discard the branch by calling the drop() command (after the branch AVPs have been created).</div><div>3. Then, I see the following errors in the log:</div><div><br></div><div>opensips[30292]: ERROR:tm:t_forward_nonack: failure to add branches</div><div>opensips[30292]: ERROR:tm:w_t_relay: t_forward_nonack failed</div><div><br></div><div>4. After that, I can see that the branch AVPs of the first branch are destroyed. However, the branch AVPs of the second branch are never destroyed.</div><div><br></div><div>I guess that creating the branch AVPs after the block that may call drop() will solve the problem but it is a workaround. It looks like a bug in OpenSIPS.</div><div><br></div><div>Thanks,</div><div>Mickael</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 16, 2015 at 5:47 PM, Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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">
    <tt>Hi, Mickael!<br>
      <br>
      Can you check if there are also any transactions hanged? Also,
      What is the scenario you are using? When are you populating these
      variables?<br>
      <br>
      Best regards,<br>
    </tt><span class="">
    <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
    </span><div><div class="h5"><div>On 07/09/2015 12:17 PM, Mickael
      Marrache wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Hi Razvan,
        <div><br>
        </div>
        <div>I have some news.</div>
        <div><br>
        </div>
        <div>The suspects are not regular AVPs but branch AVPs that I
          set in a module.</div>
        <div><br>
        </div>
        <div>Is there a specific handling for those AVPs?</div>
        <div><br>
        </div>
        <div>Here is how I use it:</div>
        <div><br>
        </div>
        <div>static str bavp_msgops_flags =
          str_init(&quot;$bavp(_msgops_bflags)&quot;);<br>
        </div>
        <div>pv_spec_t bavp_msgops_flags_spec;<br>
        </div>
        <div><br>
        </div>
        <div>In mod_init:</div>
        <div><br>
        </div>
        <div>
          <div>if (parse_store_bavp(&amp;bavp_msgops_flags,
            &amp;bavp_msgops_flags_spec)) {</div>
          <div>                LM_ERR(&quot;Fail to parse branch AVPs.\n&quot;);</div>
          <div>                return -1;</div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div>In a command called from branch_route:</div>
        <div><br>
        </div>
        <div>
          <div>b_flags.flags = PV_VAL_INT|PV_TYPE_INT;</div>
          <div>b_flags.ri = 0;</div>
          <div>if(pv_set_value(msg, &amp;bavp_msgops_flags_spec,
            (int)EQ_T, &amp;b_flags) != 0) {</div>
          <div>            LM_ERR(&quot;Fail to set branch flags AVP.\n&quot;);</div>
          <div>            return -1;</div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div>Sometimes, I do the following to get the branch AVP value:</div>
        <div><br>
        </div>
        <div>
          <div>if (pv_get_spec_value(rpl, &amp;bavp_msgops_flags_spec,
            &amp;b_flags_val) != 0) {</div>
          <div>           LM_ERR(&quot;Branch AVP not found!\n&quot;);</div>
          <div>           return;</div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Mickael</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Jul 2, 2015 at 2:34 PM, Răzvan
          Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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"> <tt>Hi, Mickael!<br>
                <br>
                Not sure why the signal is triggered. But what you could
                do is to replicate the behavior of the function until
                you find the proper id.<br>
                <br>
                Best regards,<br>
              </tt><span>
                <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
              </span>
              <div>
                <div>
                  <div>On 06/23/2015 05:37 PM, Mickael Marrache wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">Hi Razvan,
                      <div><br>
                      </div>
                      <div>I&#39;m using GDB as follows:</div>
                      <div><br>
                      </div>
                      <div>
                        <div>(gdb) p get_avp_name_id(((struct
                          usr_avp*)0x2ba445441948)-&gt;id)</div>
                        <div><br>
                        </div>
                        <div>Program received signal SIGUSR2, User
                          defined signal 2.</div>
                        <div>get_avp_name_id (id=139) at usr_avp.c:263</div>
                        <div>263     {</div>
                        <div>The program being debugged was signaled
                          while in a function called from GDB.</div>
                        <div>GDB remains in the frame where the signal
                          was received.</div>
                        <div>To change this behavior use &quot;set
                          unwindonsignal on&quot;</div>
                        <div>Evaluation of the expression containing the
                          function (get_avp_name_id) will be abandoned.</div>
                      </div>
                      <div><br>
                      </div>
                      <div>where ((struct
                        usr_avp*)0x2ba445441948)-&gt;id gives me the AVP
                        id.</div>
                      <div><br>
                      </div>
                      <div>I expect the result to be of type str*
                        (representing the AVP name) but it looks like
                        some signal is received while executing the
                        function.</div>
                      <div><br>
                      </div>
                      <div>Any idea?</div>
                      <div><br>
                      </div>
                      <div>Thanks,</div>
                      <div>Mickael </div>
                    </div>
                    <div class="gmail_extra"><br>
                      <div class="gmail_quote">On Tue, Jun 23, 2015 at
                        12:08 PM, Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank"></a><a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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"> <tt>Hi,
                              Mickael!<br>
                              <br>
                              That&#39;s the correct usage, and the AVP is
                              attached to the transaction, and destroyed
                              when the transaction is destroyed.
                              However, it depends on the context when
                              the AVP is populated. Is it done for each
                              message? Timer based?<br>
                              If I were you, I&#39;d continue tracing the
                              name of the AVPs and checking where they
                              are populated.<br>
                              <br>
                              Best regards,<br>
                            </tt><span>
                              <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
                            </span>
                            <div>
                              <div>
                                <div>On 06/22/2015 07:28 PM, Mickael
                                  Marrache wrote:<br>
                                </div>
                                <blockquote type="cite">
                                  <div dir="ltr">Looking for example at
                                    the DIALPLAN module, it looks like
                                    the same procedure is followed, so I
                                    don&#39;t see anything special I&#39;m doing
                                    here.</div>
                                  <div class="gmail_extra"><br>
                                    <div class="gmail_quote">On Mon, Jun
                                      22, 2015 at 7:22 PM, Mickael
                                      Marrache <span dir="ltr">&lt;<a href="mailto:mickaelmarrache@gmail.com" target="_blank"></a><a href="mailto:mickaelmarrache@gmail.com" target="_blank">mickaelmarrache@gmail.com</a>&gt;</span>
                                      wrote:<br>
                                      <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                        <div dir="ltr">Hi Razvan,
                                          <div><br>
                                          </div>
                                          <div>I do the following:</div>
                                          <div><br>
                                          </div>
                                          <div>
                                            <div>static str my_avp_name
                                              = {NULL, 0};</div>
                                            <div>static pv_spec_t
                                              my_avp;</div>
                                          </div>
                                          <div><br>
                                          </div>
                                          <div>
                                            <div>static param_export_t
                                              params[] = {</div>
                                            <div><span style="white-space:pre-wrap">        .....</span></div>
                                            <div><span style="white-space:pre-wrap">        </span>{
                                              &quot;my_avp&quot;,<span style="white-space:pre-wrap"> </span>STR_PARAM,


                                              &amp;my_avp_name.s}</div>
                                            <div>};</div>
                                          </div>
                                          <div><br>
                                          </div>
                                          <div>
                                            <div>static int
                                              mod_init(void) {</div>
                                            <div>        ....</div>
                                            <div><span style="white-space:pre-wrap">        my</span>_avp_name.len


                                              = strlen(my_avp_name.s);</div>
                                          </div>
                                          <div>        ....</div>
                                          <div>        if(my_avp_name.s
                                            == NULL || my_avp_name.len
                                            == 0) {</div>
                                          <div><span style="white-space:pre-wrap">                </span>return


                                            -1;</div>
                                          <div><span style="white-space:pre-wrap">        </span>}</div>
                                          <div><span style="white-space:pre-wrap">        </span>if


                                            (pv_parse_spec(&amp;my_avp_name,

                                            &amp;my_avp) == 0 ||
                                            my_avp.type != PVT_AVP) {</div>
                                          <div><span style="white-space:pre-wrap">                </span>return


                                            -1;</div>
                                          <div><span style="white-space:pre-wrap">        </span>}</div>
                                          <div>}</div>
                                          <div><br>
                                          </div>
                                          <div>Then, when I want to set
                                            a value to my AVP (for
                                            example, for setting an
                                            integer):</div>
                                          <div><br>
                                          </div>
                                          <div>pv_value_t pvar_value;<br>
                                          </div>
                                          <div>
                                            <div>pvar_value.flags =
                                              PV_VAL_INT|PV_TYPE_INT;</div>
                                            <div>pvar_value.ri =
                                              some_integer;</div>
                                            <div>if(pv_set_value(msg,
                                              &amp;my_avp, (int)EQ_T,
                                              &amp;pvar_value) &lt; 0) {</div>
                                            <div><span style="white-space:pre-wrap">        </span>goto


                                              error;</div>
                                            <div>}</div>
                                          </div>
                                          <div><br>
                                          </div>
                                          <div>And, that&#39;s all. I don&#39;t
                                            detroy the AVP after use
                                            because the module can&#39;t
                                            know the AVP is not used
                                            anymore. I can destroy the
                                            AVP in the script after use
                                            but I thought it was handled
                                            automatically.</div>
                                          <div><br>
                                          </div>
                                          <div>In the example I gave
                                            here, is the AVP attached to
                                            a transaction? What are the
                                            conditions for an AVP to be
                                            attached to a transaction?</div>
                                          <div><br>
                                          </div>
                                          <div>Thanks,</div>
                                          <div>Mickael</div>
                                        </div>
                                        <div>
                                          <div>
                                            <div class="gmail_extra"><br>
                                              <div class="gmail_quote">On
                                                Mon, Jun 22, 2015 at
                                                10:33 AM, Răzvan Crainea
                                                <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank"></a><a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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"> <tt>Hi,
                                                      Mickael!<br>
                                                      <br>
                                                      Both maps are
                                                      relevant, because
                                                      both of them
                                                      contain id2name
                                                      mappings. So you
                                                      should definitely
                                                      look into the
                                                      avp_map too. Note
                                                      that those
                                                      mappings do not
                                                      store AVPs, they
                                                      only store the
                                                      real name of the
                                                      AVP, as you use in
                                                      script, and they
                                                      can be populated
                                                      at startup (in
                                                      this case they are
                                                      stored in PKG) and
                                                      runtime (stored in
                                                      SHM).<br>
                                                      It depends when
                                                      the AVP should be
                                                      destroyed: if they
                                                      are attached to
                                                      the transaction
                                                      (and they usually
                                                      are), they are
                                                      automatically
                                                      destroyed by the
                                                      tm module.
                                                      Otherwise the
                                                      module that uses
                                                      them, should take
                                                      care of that.<br>
                                                      <br>
                                                      Best regards,<br>
                                                    </tt><span>
                                                      <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
                                                    </span>
                                                    <div>
                                                      <div>
                                                        <div>On
                                                          06/18/2015
                                                          09:56 PM,
                                                          Mickael
                                                          Marrache
                                                          wrote:<br>
                                                        </div>
                                                        <blockquote type="cite">
                                                          <div dir="ltr">Hi
                                                          Razvan,
                                                          <div><br>
                                                          </div>
                                                          <div>I looked
                                                          at both
                                                          avp_map and
                                                          avp_map_shm.
                                                          In our case,
                                                          only
                                                          avp_map_shm is
                                                          relevant since
                                                          the leak
                                                          appears in
                                                          shared memory.
                                                          I only see 4
                                                          elements in
                                                          this map while
                                                          I can see a
                                                          lot of
                                                          remaining AVPs
                                                          when looking
                                                          at the memory
                                                          dump created
                                                          at shutdown
                                                          using QM
                                                          debug.
                                                          Therefore, it
                                                          looks like
                                                          these AVPs are
                                                          not in the
                                                          map. Looking
                                                          at the new_avp
                                                          function in
                                                          usr_avp.c, I
                                                          don&#39;t see at
                                                          any moment
                                                          that an entry
                                                          is added to
                                                          the map for
                                                          the new AVP.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>
                                                          <div>(gdb)
                                                          print
                                                          avp_map_shm-&gt;avl_count</div>
                                                          <div>$5 = 4</div>
                                                          <div>(gdb)
                                                          print
                                                          avp_map-&gt;avl_count</div>
                                                          <div>$6 = 140</div>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div>Any idea?</div>
                                                          <div><br>
                                                          </div>
                                                          <div>At which
                                                          moment during
                                                          execution an
                                                          AVP is
                                                          destroyed? Is
                                                          it required
                                                          for modules
                                                          returning
                                                          values to
                                                          script through
                                                          AVPs to
                                                          destroy these
                                                          AVPs? or are
                                                          they
                                                          automatically
                                                          destroyed?</div>
                                                          <div><br>
                                                          </div>
                                                          <div>Thanks,</div>
                                                          <div>Mickael</div>
                                                          </div>
                                                          <div class="gmail_extra"><br>
                                                          <div class="gmail_quote">On

                                                          Thu, Jun 18,
                                                          2015 at 7:33
                                                          PM, Răzvan
                                                          Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank"></a><a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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">
                                                          <tt><span>Hi,
                                                          Mickael!<br>
                                                          <br>
                                                          This is not
                                                          entirely true
                                                          - you can
                                                          define AVPs
                                                          with the
                                                          integer value
                                                          0. Those will
                                                          have
                                                          avp-&gt;flags
                                                          == 0 and
                                                          avp-&gt;data
                                                          == 0.<br>
                                                          What I&#39;d do,
                                                          is to note
                                                          down the
                                                          avp-&gt;id
                                                          value of those
                                                          AVPs and then
                                                          try to see
                                                          their names.
                                                          To do that,
                                                          you&#39;d have to
                                                          look into the
                                                          avp_map and
                                                          avp_map_shm
                                                          maps to see
                                                          the
                                                          corresponding
                                                          name for that
                                                          id.
                                                          Alternatively
                                                          you can call
                                                          in your script
                                                          the
                                                          avp_print()
                                                          method, which
                                                          prints all the
                                                          AVPs for a
                                                          specific
                                                          transaction
                                                          along with
                                                          their id and
                                                          names. Let me
                                                          know how this
                                                          goes.<br>
                                                          <br>
                                                          </span> Best
                                                          regards,</tt><span>
                                                          <pre cols="72">Răzvan Crainea
OpenSIPS Solutions
<a href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a>
</pre>
                                                          </span></div>
                                                          </blockquote>
                                                          </div>
                                                          </div>
                                                        </blockquote>
                                                      </div>
                                                    </div>
                                                  </div>
                                                </blockquote>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </blockquote>
                                    </div>
                                  </div>
                                </blockquote>
                              </div>
                            </div>
                          </div>
                          <br>
_______________________________________________<br>
                          Users mailing list<br>
                          <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
                          <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                    <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Users mailing list<br>
            <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
            <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>