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

Chaigneau, Nicolas nicolas.chaigneau at capgemini.com
Wed Jan 20 18:25:33 CET 2021


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210120/5534a3fe/attachment.htm>


More information about the sr-users mailing list