Discussion:
[SR-Users] mt_match avp behavior
Juha Heinanen
2014-09-05 10:16:22 UTC
Permalink
looking at the code, i appears that mt_match does not initialize
pv_values pv when it stores matched values thus keeping possible
existing values from previous calls. is that intended behavior? readme
uses word "store".

-- juha
Daniel-Constantin Mierla
2014-09-05 12:41:31 UTC
Permalink
Post by Juha Heinanen
looking at the code, i appears that mt_match does not initialize
pv_values pv when it stores matched values thus keeping possible
existing values from previous calls. is that intended behavior? readme
uses word "store".
Don't remember by hard exactly what to refer to, but if it is about
result pv, some types cannot be initialized (e.g., avp/xavp).

If you have something particular in mind, make a patch and we can see if
there is any side effect. Otherwise, I would expect to use the result pv
only if the match is successful, therefore not needing/expecting the
previous values.

Cheers,
Daniel
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Juha Heinanen
2014-09-05 12:57:51 UTC
Permalink
Post by Daniel-Constantin Mierla
Post by Juha Heinanen
looking at the code, i appears that mt_match does not initialize
pv_values pv when it stores matched values thus keeping possible
existing values from previous calls. is that intended behavior? readme
uses word "store".
Don't remember by hard exactly what to refer to, but if it is about
result pv, some types cannot be initialized (e.g., avp/xavp).
If you have something particular in mind, make a patch and we can see if
there is any side effect. Otherwise, I would expect to use the result pv
only if the match is successful, therefore not needing/expecting the
previous values.
i would just like to call destroy_avps, before starting to add matching
values to the avp. otherwise the avp may have old values from previous
mt_match call.

-- juha
Daniel-Constantin Mierla
2014-09-05 13:00:45 UTC
Permalink
Post by Juha Heinanen
Post by Daniel-Constantin Mierla
Post by Juha Heinanen
looking at the code, i appears that mt_match does not initialize
pv_values pv when it stores matched values thus keeping possible
existing values from previous calls. is that intended behavior? readme
uses word "store".
Don't remember by hard exactly what to refer to, but if it is about
result pv, some types cannot be initialized (e.g., avp/xavp).
If you have something particular in mind, make a patch and we can see if
there is any side effect. Otherwise, I would expect to use the result pv
only if the match is successful, therefore not needing/expecting the
previous values.
i would just like to call destroy_avps, before starting to add matching
values to the avp. otherwise the avp may have old values from previous
mt_match call.
IIRC, there can be other types of variables used to store the result,
thus I am not sure that is easily possible for all cases.

If you get a patch you think is solving it, then I would not mind having
it if there are no side effects.

Cheers,
Daniel
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Juha Heinanen
2014-09-05 13:07:44 UTC
Permalink
Post by Daniel-Constantin Mierla
IIRC, there can be other types of variables used to store the result,
thus I am not sure that is easily possible for all cases.
doesn't this values_param check mean that the param must be avp?

if (pv_parse_spec(&values_param, &pv_values) <0
|| pv_values.type != PVT_AVP) {
LM_ERR("cannot parse values avp\n");
return -1;
}

-- juha
Daniel-Constantin Mierla
2014-09-05 13:20:34 UTC
Permalink
Post by Juha Heinanen
Post by Daniel-Constantin Mierla
IIRC, there can be other types of variables used to store the result,
thus I am not sure that is easily possible for all cases.
doesn't this values_param check mean that the param must be avp?
if (pv_parse_spec(&values_param, &pv_values) <0
|| pv_values.type != PVT_AVP) {
LM_ERR("cannot parse values avp\n");
return -1;
}
I had in mind pv_value (which I added), but I see there is also
pv_values (most probably added by you?!?), which I don't remember using
it for my configs.
Looks like it is ok to add that given the restrictions on pv type. If
nobody else has concerns on side effects, it is fine for me to call
destroy avps.

Cheers,
Daniel
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Loading...