[SR-Users] [kamailio 5.4.3] xavp_rm_by_index removes (N+1) first indexes instead of index N

Daniel-Constantin Mierla miconda at gmail.com
Wed Jan 20 19:35:06 CET 2021


Hello,

looking at the code, I cannot spot anything wrong with xavp_rm_internal().

Being about C code you wrote, can you double check your code or share the
entire function you tested with?

Cheers,
Daniel

On Wed, Jan 20, 2021 at 6:26 PM Chaigneau, Nicolas <
nicolas.chaigneau at capgemini.com> wrote:

> Hello
>
>
>
>
>
> I’m trying to use function xavp_rm_by_index to remove a specific index
> from a given xavp.
>
> I’m observing an unexpected behaviour, I think it might be a bug :
>
> Instead of just removing the index, the function removes the index and all
> others before it.
>
>
>
> E.g : if called with « idx = 1 », it removes indexes 0 and 1.
>
>
>
>
>
> Reading the code of xavp_rm_internal (which is called by
> xavp_rm_by_index), I don’t think it behaves at it should :
>
>
>
> /* Remove xavps
>
> * idx: <0 remove all xavps with the same name
>
> *      >=0 remove only the specified index xavp
>
> * Returns number of xavps that were deleted
>
> */
>
>
>
>
>
> For example when I do this :
>
>
>
> LM_ERR("COUNT BEFORE: %d\n", xavp_count(rname, NULL));
>
> int rm_count = xavp_rm_by_index(rname, 1, NULL); // TEST
>
> LM_ERR("REMOVED: %d\n", rm_count);
>
> LM_ERR("COUNT AFTER: %d\n", xavp_count(rname, NULL));
>
>
>
>
>
> « rm_count » returned is 1 (which is expected). However, « count after »
> is decremented by 2.
>
> And when I look at the contents of my xavp, I notice that the first two
> elements have been removed.
>
>
>
> Likewise if xavp_rm_by_index is invoked with idx = 2 => the first 3
> elements are removed.
>
>
>
>
>
>
>
> So… do you think this is a bug ? or something I didn’t understand ?
>
>
>
>
>
> Thanks for your help !
>
>
>
>
>
> Regards,
>
> Nicolas.
>
>
> This message contains information that may be privileged or confidential
> and is the property of the Capgemini Group. It is intended only for the
> person to whom it is addressed. If you are not the intended recipient, you
> are not authorized to read, print, retain, copy, disseminate, distribute,
> or use this message or any part thereof. If you receive this message in
> error, please notify the sender immediately and delete all copies of this
> message.
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>


-- 
Daniel-Constantin Mierla - https://www.asipto.com
https://twitter.com/miconda - https://www.linkedin.com/in/miconda
Kamailio Advanced Training - https://www.asipto.com/u/kat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210120/1091d471/attachment.htm>


More information about the sr-users mailing list