Hello,

Here is some code that shows the issue :


1) a test cmd_function in a module defined as follows :

static int was_test(struct sip_msg *msg, char *param1, char *param2);

static cmd_export_t cmds[] = {
       {"was_test", (cmd_function)was_test, 2, 0, 0, ANY_ROUTE},
       {0, 0, 0, 0, 0, 0}
};

/**
* For testing purposes.
*/
static int was_test(struct sip_msg *msg, char *param1, char *param2)
{
       LM_WARN("Called with param1: [%s], param2: [%s]\n", param1, param2);

       str my_str;
       my_str.s = param1;
       my_str.len = strlen(param1);

       int idx = atoi(param2);
       str *rname = &my_str;

       LM_ERR("COUNT BEFORE: %d\n", xavp_count(rname, NULL));

       int rm_count = xavp_rm_by_index(rname, idx, NULL);

       LM_ERR("REMOVED: %d\n", rm_count);
       LM_ERR("COUNT AFTER: %d\n", xavp_count(rname, NULL));

       return 1;
}



2) Kamailio script :

request_route {

       # push 4 rows to xavp "test":
       $xavp(test=>a) = "3.a";
       $xavp(test[0]=>b) = "3.b";

       $xavp(test=>a) = "2.a";
       $xavp(test[0]=>b) = "2.b";

       $xavp(test=>a) = "1.a";
       $xavp(test[0]=>b) = "1.b";

       $xavp(test=>a) = "0.a";
       $xavp(test[0]=>b) = "0.b";

       # then try to call xavp_rm_by_index with a non-zero idx
       xlog("L_INFO", "BEFORE\n");
       xlog("L_INFO", "test[*]: [$(was_xavp_serialize(test)[*])]\n");
       pv_xavp_print();

       was_test("test", "1"); // expecting only row 1 to be removed (1.a / 1.b)

       xlog("L_INFO", "AFTER\n");
       xlog("L_INFO", "test[*]: [$(was_xavp_serialize(test)[*])]\n");
       pv_xavp_print();

}



And the resulting logs :

2(16546) INFO: {1 INVITE [email protected]} <script>: BEFORE
2(16546) INFO: {1 INVITE [email protected]} <script>: test[*]: 
[(0):b=0.b;a=0.a, (1):b=1.b;a=1.a, (2):b=2.b;a=2.a, (3):b=3.b;a=3.a]
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff798 ((nil)) 
(level=0)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff798) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff840>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff840 
(0x7f7193dff7b8) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff840) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 0.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff840) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff6f0) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 0.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff6f0) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff840 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff798) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff5a0) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff648>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff648 
(0x7f7193dff5c0) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff648) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 1.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff648) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff4f8) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 1.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff4f8) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff648 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff5a0) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff450>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff450 
(0x7f7193dff3c8) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff450 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff258>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff258 
(0x7f7193dff1d0) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff258 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff798 (level=0)
2(16546) WARNING: {1 INVITE [email protected]} was_utils [was_utils.c:169]: 
was_test(): Called with param1: [test], param2: [1]
2(16546) ERROR: {1 INVITE [email protected]} was_utils [was_utils.c:178]: 
was_test(): COUNT BEFORE: 4
2(16546) ERROR: {1 INVITE [email protected]} was_utils [was_utils.c:180]: 
was_test(): REMOVED: 1
2(16546) ERROR: {1 INVITE [email protected]} was_utils [was_utils.c:181]: 
was_test(): COUNT AFTER: 2
2(16546) INFO: {1 INVITE [email protected]} <script>: AFTER
2(16546) INFO: {1 INVITE [email protected]} <script>: test[*]: 
[(0):b=2.b;a=2.a, (1):b=3.b;a=3.a]
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff3a8 ((nil)) 
(level=0)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff450>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff450 
(0x7f7193dff3c8) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff450 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff258>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff258 
(0x7f7193dff1d0) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff258 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff3a8 (level=0)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff3a8 ((nil)) 
(level=0)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff450>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff450 
(0x7f7193dff3c8) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff450) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 2.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff300) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff450 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff3a8) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) XAVP name: test
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 2063405720
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 6
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:629]: 
xavx_print_list_content():      XAVP value: <xavp:0x7f7193dff258>
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:601]: 
xavx_print_list_content(): +++++ start XAVP list: 0x7f7193dff258 
(0x7f7193dff1d0) (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) XAVP name: b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 110
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.b
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff258) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:605]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) XAVP name: a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:606]: 
xavx_print_list_content():      XAVP id: 109
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:607]: 
xavx_print_list_content():      XAVP value type: 2
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:616]: 
xavx_print_list_content():      XAVP value (str): 3.a
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:1 - 0x7f7193dff108) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff258 (level=1)
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:642]: 
xavx_print_list_content():      *** (l:0 - 0x7f7193dff1b0) end
2(16546) INFO: {1 INVITE [email protected]} <core> [core/xavp.c:645]: 
xavx_print_list_content(): ----- end XAVP list: 0x7f7193dff3a8 (level=0)




Regards,
Nicolas.

De : sr-users <[email protected]> De la part de 
Daniel-Constantin Mierla
Envoyé : mercredi 20 janvier 2021 19:35
À : Kamailio (SER) - Users Mailing List
Objet : Re: [SR-Users] [kamailio 5.4.3] xavp_rm_by_index removes (N+1) first 
indexes instead of index N

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 
<[email protected]<mailto:[email protected]>> 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
[email protected]<mailto:[email protected]>
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
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to