[SR-Users] t_lookup_request()

Daniel-Constantin Mierla miconda at gmail.com
Wed May 13 13:32:08 CEST 2015


Hello,

I haven't implemented the function, nor use it for my configs, but I
expect that it doesn't create the transaction, it just searches to see
if it exists.

More comments inline.

On 12/05/15 23:53, Alex Balashov wrote:
> Hello,
>
> From the documentation for t_lookup_request()[1], it is not clear
> whether it creates a new transaction if one does not exist:
>
>    "Checks if a transaction exists. Returns a positive value
>     if so, negative otherwise. Most likely you will not want to
>     use it, as a typical application of a look-up is to introduce
>     a new transaction if none was found. However this is safely
>    (atomically) done using t_newtran."
>
> This language is quite unclear in the following respects:
>
> 1) Why would I not want to use it?

What is the main role of knowing if the transaction exists for you in
the config?

>
> 2) Does the "typical application" mean that t_lookup_request() _will_
> create a new transaction if one does not exist?

I expect to not to create the transaction. Perhaps this is visible by
running with debug=3 and doing a small test -- could be faster than
checking the code.

>
> 3) Do I have some means of choosing whether to invoke
> t_lookup_request() in a "typical" or "atypical" application?

Again, I never used it and can't imagine a need to use it right now. I
care not to be a retransmission in my config, but I use the new
mechanism with t_precheck_trans(), which is lightweight and does the
job. Later is a just matter of the action is after t_relay() or not to
know if it is a transaction active, but again, I don't really need to
know the transaction is there as long as I filter out retransmissions.

>
> 4) This statement "this is safely (atomically) done using t_newtran"
> implies that creating a new transaction using t_lookup_request()
> (which also implies that yes, it does create a new transaction) is
> "unsafe" and "non-atomic". Why is this?
>

Again, rather old tm code that just work, so can't remember by heart and
no much time to dig in. But t_newtran() is creating the transaction if
doesn't exit. If it exists, it will stop execution of the config file
(i.e., retransmission handling) if that transaction is not the active
one for the config in that moment.

> 5) Does this mean that the effect here would be to create two
> transactions?
>
>    if(!t_lookup_request())
>       t_newtran();

Never will be two transactions for same request.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com




More information about the sr-users mailing list