Module: sip-router Branch: master Commit: 392becb3e592f06f4ff843b303f1ddc765fa1a9f URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=392becb3...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Aug 18 22:05:30 2014 +0200
tmx: documentation for t_precheck_trans()
---
modules/tmx/README | 28 +++++++++++++++++++++++++++- modules/tmx/doc/tmx_admin.xml | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/modules/tmx/README b/modules/tmx/README index 73eba24..80e6a45 100644 --- a/modules/tmx/README +++ b/modules/tmx/README @@ -47,6 +47,7 @@ Juha Heinanen 3.8. t_suspend() 3.9. t_continue(tindex, tlabel, rtname) 3.10. t_reuse_branch() + 3.11. t_precheck_trans()
4. Exported pseudo-variables 5. MI Commands @@ -83,6 +84,7 @@ Juha Heinanen 1.8. t_suspend usage 1.9. t_continue usage 1.10. t_reuse_branch usage + 1.11. t_precheck_trans usage
Chapter 1. Admin Guide
@@ -106,6 +108,7 @@ Chapter 1. Admin Guide 3.8. t_suspend() 3.9. t_continue(tindex, tlabel, rtname) 3.10. t_reuse_branch() + 3.11. t_precheck_trans()
4. Exported pseudo-variables 5. MI Commands @@ -135,7 +138,7 @@ Chapter 1. Admin Guide This module collects extensions from Kamailio TM module.
Kamailio TM (Transaction Management) module documentation is available - at: http://www.kamailio.org/docs/modules/1.5.x/tm.html + at: http://www.kamailio.org/docs/modules/stable/tm.html
2. Dependencies
@@ -165,6 +168,7 @@ Chapter 1. Admin Guide 3.8. t_suspend() 3.9. t_continue(tindex, tlabel, rtname) 3.10. t_reuse_branch() + 3.11. t_precheck_trans()
3.1. t_cancel_branches(which)
@@ -350,6 +354,28 @@ event_route [tm:branch-failure:contact] { } ...
+3.11. t_precheck_trans() + + Check if current processed message is handled by other process. This + function is useful to catch retransmissions before transaction is + created. The function returns true if the request is handled by another + process. + + Note that ACK and CANCEL requests are not tracked by this function, the + return code being false for them. + + This function can be used from REQUEST_ROUTE . + + Example 1.11. t_precheck_trans usage +... + # handle retransmissions + if(t_precheck_trans()) { + t_check_trans(); + exit; + } + t_check_trans(); +... + 4. Exported pseudo-variables
* $T_branch_idx diff --git a/modules/tmx/doc/tmx_admin.xml b/modules/tmx/doc/tmx_admin.xml index 643281b..029c943 100644 --- a/modules/tmx/doc/tmx_admin.xml +++ b/modules/tmx/doc/tmx_admin.xml @@ -20,8 +20,8 @@ </para> <para> &kamailio; TM (Transaction Management) module documentation is available at: - <ulink url="http://www.kamailio.org/docs/modules/1.5.x/tm.html"> - http://www.kamailio.org/docs/modules/1.5.x/tm.html</ulink> + <ulink url="http://www.kamailio.org/docs/modules/stable/tm.html"> + http://www.kamailio.org/docs/modules/stable/tm.html</ulink> </para> </section> @@ -370,6 +370,37 @@ event_route [tm:branch-failure:contact] { </programlisting> </example> </section> + <section> + <title> + <function moreinfo="none">t_precheck_trans()</function> + </title> + <para> + Check if current processed message is handled by other process. + This function is useful to catch retransmissions before transaction + is created. The function returns true if the request is handled by + another process. + </para> + <para> + Note that ACK and CANCEL requests are not tracked by this function, + the return code being false for them. + </para> + <para> + This function can be used from REQUEST_ROUTE . + </para> + <example> + <title><function>t_precheck_trans</function> usage</title> + <programlisting format="linespecific"> +... + # handle retransmissions + if(t_precheck_trans()) { + t_check_trans(); + exit; + } + t_check_trans(); +... +</programlisting> + </example> + </section>
</section>
Daniel-Constantin Mierla writes:
- Example 1.11. t_precheck_trans usage
+...
- # handle retransmissions
- if(t_precheck_trans()) {
t_check_trans();
exit;
- }
- t_check_trans();
why t_check_trans() is called when t_precheck_trans() returns true? why exit is not enough?
-- juha
On 19/08/14 09:07, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
- Example 1.11. t_precheck_trans usage
+...
- # handle retransmissions
- if(t_precheck_trans()) {
t_check_trans();
exit;
- }
- t_check_trans();
why t_check_trans() is called when t_precheck_trans() returns true? why exit is not enough?
The purpose of t_check_trans() there is for the case when the transaction was already created by another process, resulting in retransmitting back the last reply (what rfc recommends).
Practically, t_precheck_trans() stores the callid/from-tag/cseq/via-branch in a shared memory structure and checks if another process has the same values. It can be the case of a match, but the other process can be ahead with processing and the transaction was created for that request.
I considered of doing t_check_trans() from inside t_precheck_trans(), but then I thought it gives more flexibility via config. t_precheck_trans() should be very fast, these structures are indexed by call id in a hash table, only when a child handles a request with request_route.
If you just want to drop the retransmission, you can skip t_check_trans() inside the if.
Cheers, Daniel
Daniel-Constantin Mierla writes:
The purpose of t_check_trans() there is for the case when the transaction was already created by another process, resulting in retransmitting back the last reply (what rfc recommends).
thanks for the clarification. tm readme does not mention that t_check_trans() sends back a reply.
-- juha
On 19/08/14 10:31, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
The purpose of t_check_trans() there is for the case when the transaction was already created by another process, resulting in retransmitting back the last reply (what rfc recommends).
thanks for the clarification. tm readme does not mention that t_check_trans() sends back a reply.
I added some details about it the readme.
Cheers, Daniel
i tried this code:
if(t_precheck_trans()) { t_check_trans(); exit; } t_check_trans();
and got a crash.
-- juha
(gdb) where #0 0x00007fa3d6e994c0 in tmx_check_pretran (msg=0x7fa3e4db3d88) at tmx_pretran.c:225 #1 0x00007fa3d6e97deb in w_t_precheck_trans (msg=0x7fa3e4db3d88, p1=0x0, p2=0x0) at tmx_mod.c:709 #2 0x000000000041c6b3 in do_action (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1107 #3 0x0000000000425233 in run_actions (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1607 #4 0x000000000042591f in run_actions_safe (h=0x7fff756e8990, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1672 #5 0x00000000004cb56f in rval_get_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, i=0x7fff756e8800, rv=0x7fa3e44df558, cache=0x0) at rvalue.c:924 #6 0x00000000004ce227 in rval_expr_eval_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, res=0x7fff756e8800, rve=0x7fa3e44df550) at rvalue.c:1918 #7 0x000000000041c3d6 in do_action (h=0x7fff756e8990, a=0x7fa3e44dfed0, msg=0x7fa3e4db3d88) at action.c:1083 #8 0x0000000000425233 in run_actions (h=0x7fff756e8990, a=0x7fa3e44d3228, msg=0x7fa3e4db3d88) at action.c:1607 #9 0x00000000004259e7 in run_top_route (a=0x7fa3e44d3228, msg=0x7fa3e4db3d88, c=0x0) at action.c:1693 #10 0x00000000004ab495 in receive_msg ( buf=0x199b390 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750) at receive.c:213 #11 0x0000000000533b6e in receive_tcp_msg ( tcpbuf=0x7fa3db3fba20 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750, con=0x7fa3db3fb738) at tcp_read.c:1232 #12 0x0000000000534a20 in tcp_read_req (con=0x7fa3db3fb738, bytes_read=0x7fff756e8dec, read_flags=0x7fff756e8de8) at tcp_read.c:1387 #13 0x0000000000535e0c in handle_io (fm=0x7fa3e4e934f0, events=1, idx=-1) at tcp_read.c:1559 #14 0x000000000052edd9 in io_wait_loop_epoll (h=0x8e4200, t=2, repeat=0) at io_wait.h:1092 #15 0x0000000000536ce2 in tcp_receive_loop (unix_sock=49) at tcp_read.c:1728 #16 0x000000000052929f in tcp_init_children () at tcp_main.c:4970 #17 0x0000000000470d9d in main_loop () at main.c:1704 #18 0x00000000004739ae in main (argc=17, argv=0x7fff756e92b8) at main.c:2554 (gdb) #0 0x00007fa3d6e994c0 in tmx_check_pretran (msg=0x7fa3e4db3d88) at tmx_pretran.c:225 #1 0x00007fa3d6e97deb in w_t_precheck_trans (msg=0x7fa3e4db3d88, p1=0x0, p2=0x0) at tmx_mod.c:709 #2 0x000000000041c6b3 in do_action (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1107 #3 0x0000000000425233 in run_actions (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1607 #4 0x000000000042591f in run_actions_safe (h=0x7fff756e8990, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1672 #5 0x00000000004cb56f in rval_get_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, i=0x7fff756e8800, rv=0x7fa3e44df558, cache=0x0) at rvalue.c:924 #6 0x00000000004ce227 in rval_expr_eval_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, res=0x7fff756e8800, rve=0x7fa3e44df550) at rvalue.c:1918 #7 0x000000000041c3d6 in do_action (h=0x7fff756e8990, a=0x7fa3e44dfed0, msg=0x7fa3e4db3d88) at action.c:1083 #8 0x0000000000425233 in run_actions (h=0x7fff756e8990, a=0x7fa3e44d3228, msg=0x7fa3e4db3d88) at action.c:1607 #9 0x00000000004259e7 in run_top_route (a=0x7fa3e44d3228, msg=0x7fa3e4db3d88, c=0x0) at action.c:1693 #10 0x00000000004ab495 in receive_msg ( buf=0x199b390 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750) at receive.c:213 #11 0x0000000000533b6e in receive_tcp_msg ( tcpbuf=0x7fa3db3fba20 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750, con=0x7fa3db3fb738) at tcp_read.c:1232 #12 0x0000000000534a20 in tcp_read_req (con=0x7fa3db3fb738, bytes_read=0x7fff756e8dec, read_flags=0x7fff756e8de8) at tcp_read.c:1387 #13 0x0000000000535e0c in handle_io (fm=0x7fa3e4e934f0, events=1, idx=-1) at tcp_read.c:1559 #14 0x000000000052edd9 in io_wait_loop_epoll (h=0x8e4200, t=2, repeat=0) at io_wait.h:1092 #15 0x0000000000536ce2 in tcp_receive_loop (unix_sock=49) at tcp_read.c:1728 #16 0x000000000052929f in tcp_init_children () at tcp_main.c:4970 #17 0x0000000000470d9d in main_loop () at main.c:1704 #18 0x00000000004739ae in main (argc=17, argv=0x7fff756e92b8) at main.c:2554
Fixed -- it was missing safety check for From header parsing.
Cheers, Daniel
On 19/08/14 11:05, Juha Heinanen wrote:
i tried this code:
if(t_precheck_trans()) { t_check_trans(); exit; } t_check_trans();
and got a crash.
-- juha
(gdb) where #0 0x00007fa3d6e994c0 in tmx_check_pretran (msg=0x7fa3e4db3d88) at tmx_pretran.c:225 #1 0x00007fa3d6e97deb in w_t_precheck_trans (msg=0x7fa3e4db3d88, p1=0x0, p2=0x0) at tmx_mod.c:709 #2 0x000000000041c6b3 in do_action (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1107 #3 0x0000000000425233 in run_actions (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1607 #4 0x000000000042591f in run_actions_safe (h=0x7fff756e8990, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1672 #5 0x00000000004cb56f in rval_get_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, i=0x7fff756e8800, rv=0x7fa3e44df558, cache=0x0) at rvalue.c:924 #6 0x00000000004ce227 in rval_expr_eval_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, res=0x7fff756e8800, rve=0x7fa3e44df550) at rvalue.c:1918 #7 0x000000000041c3d6 in do_action (h=0x7fff756e8990, a=0x7fa3e44dfed0, msg=0x7fa3e4db3d88) at action.c:1083 #8 0x0000000000425233 in run_actions (h=0x7fff756e8990, a=0x7fa3e44d3228, msg=0x7fa3e4db3d88) at action.c:1607 #9 0x00000000004259e7 in run_top_route (a=0x7fa3e44d3228, msg=0x7fa3e4db3d88, c=0x0) at action.c:1693 #10 0x00000000004ab495 in receive_msg ( buf=0x199b390 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750) at receive.c:213 #11 0x0000000000533b6e in receive_tcp_msg ( tcpbuf=0x7fa3db3fba20 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750, con=0x7fa3db3fb738) at tcp_read.c:1232 #12 0x0000000000534a20 in tcp_read_req (con=0x7fa3db3fb738, bytes_read=0x7fff756e8dec, read_flags=0x7fff756e8de8) at tcp_read.c:1387 #13 0x0000000000535e0c in handle_io (fm=0x7fa3e4e934f0, events=1, idx=-1) at tcp_read.c:1559 #14 0x000000000052edd9 in io_wait_loop_epoll (h=0x8e4200, t=2, repeat=0) at io_wait.h:1092 #15 0x0000000000536ce2 in tcp_receive_loop (unix_sock=49) at tcp_read.c:1728 #16 0x000000000052929f in tcp_init_children () at tcp_main.c:4970 #17 0x0000000000470d9d in main_loop () at main.c:1704 #18 0x00000000004739ae in main (argc=17, argv=0x7fff756e92b8) at main.c:2554 (gdb) #0 0x00007fa3d6e994c0 in tmx_check_pretran (msg=0x7fa3e4db3d88) at tmx_pretran.c:225 #1 0x00007fa3d6e97deb in w_t_precheck_trans (msg=0x7fa3e4db3d88, p1=0x0, p2=0x0) at tmx_mod.c:709 #2 0x000000000041c6b3 in do_action (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1107 #3 0x0000000000425233 in run_actions (h=0x7fff756e80e0, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1607 #4 0x000000000042591f in run_actions_safe (h=0x7fff756e8990, a=0x7fa3e44df2c8, msg=0x7fa3e4db3d88) at action.c:1672 #5 0x00000000004cb56f in rval_get_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, i=0x7fff756e8800, rv=0x7fa3e44df558, cache=0x0) at rvalue.c:924 #6 0x00000000004ce227 in rval_expr_eval_int (h=0x7fff756e8990, msg=0x7fa3e4db3d88, res=0x7fff756e8800, rve=0x7fa3e44df550) at rvalue.c:1918 #7 0x000000000041c3d6 in do_action (h=0x7fff756e8990, a=0x7fa3e44dfed0, msg=0x7fa3e4db3d88) at action.c:1083 #8 0x0000000000425233 in run_actions (h=0x7fff756e8990, a=0x7fa3e44d3228, msg=0x7fa3e4db3d88) at action.c:1607 #9 0x00000000004259e7 in run_top_route (a=0x7fa3e44d3228, msg=0x7fa3e4db3d88, c=0x0) at action.c:1693 #10 0x00000000004ab495 in receive_msg ( buf=0x199b390 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750) at receive.c:213 #11 0x0000000000533b6e in receive_tcp_msg ( tcpbuf=0x7fa3db3fba20 "NOTIFY sip:test-0x1d81ce0@192.98.102.30:5064;alias=192.98.102.30~37384~2;transport=tcp SIP/2.0\r\nVia: SIP/2.0/TCP 192.98.102.30:5080;branch=z9hG4bK5d1b.05567df1", '0' <repeats 24 times>, ".0\r\nTo: <sip:test"..., len=677, rcv_info=0x7fa3db3fb750, con=0x7fa3db3fb738) at tcp_read.c:1232 #12 0x0000000000534a20 in tcp_read_req (con=0x7fa3db3fb738, bytes_read=0x7fff756e8dec, read_flags=0x7fff756e8de8) at tcp_read.c:1387 #13 0x0000000000535e0c in handle_io (fm=0x7fa3e4e934f0, events=1, idx=-1) at tcp_read.c:1559 #14 0x000000000052edd9 in io_wait_loop_epoll (h=0x8e4200, t=2, repeat=0) at io_wait.h:1092 #15 0x0000000000536ce2 in tcp_receive_loop (unix_sock=49) at tcp_read.c:1728 #16 0x000000000052929f in tcp_init_children () at tcp_main.c:4970 #17 0x0000000000470d9d in main_loop () at main.c:1704 #18 0x00000000004739ae in main (argc=17, argv=0x7fff756e92b8) at main.c:2554
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev