Skip to content

Commit

Permalink
modukles/tm: added t_clean() script function
Browse files Browse the repository at this point in the history
  • Loading branch information
juha-h committed Mar 6, 2020
1 parent eb4f66d commit 51d95e0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
26 changes: 20 additions & 6 deletions src/modules/tm/README
Expand Up @@ -135,6 +135,7 @@ Daniel-Constantin Mierla
body)

4.54. t_get_status_code()
4.55. t_clean()

5. RPC Commands

Expand Down Expand Up @@ -270,9 +271,10 @@ Daniel-Constantin Mierla
1.94. t_is_retr_async_reply usage
1.95. t_uac_send usage
1.96. t_get_status_code usage
1.97. event_route[tm:branch-failure:id] usage
1.98. event_route[tm:local-request] usage
1.99. event_route[tm:local-response] usage
1.97. t_clean usage
1.98. event_route[tm:branch-failure:id] usage
1.99. event_route[tm:local-request] usage
1.100. event_route[tm:local-response] usage

Chapter 1. Admin Guide

Expand Down Expand Up @@ -388,6 +390,7 @@ Chapter 1. Admin Guide
4.52. t_is_retr_async_reply()
4.53. t_uac_send(method, ruri, nexthop, socket, headers, body)
4.54. t_get_status_code()
4.55. t_clean()

5. RPC Commands

Expand Down Expand Up @@ -1740,6 +1743,7 @@ modparam("tm", "rich_redirect", 3)
4.52. t_is_retr_async_reply()
4.53. t_uac_send(method, ruri, nexthop, socket, headers, body)
4.54. t_get_status_code()
4.55. t_clean()

4.1. t_relay([host, port])

Expand Down Expand Up @@ -2912,6 +2916,16 @@ $var(ts) = t_get_status_code();
if($var(ts) == 500) { ... }
...

4.55. t_clean()

Cleans active but very old transactions. Returns true (1). Can be
called from any route.

Example 1.97. t_clean usage
...
t_clean();
...

5. RPC Commands

5.1. tm.list
Expand Down Expand Up @@ -3025,7 +3039,7 @@ if($var(ts) == 500) { ... }
enabled with the t_on_branch_failure function. This event_route uses
the BRANCH_FAILURE_ROUTE route type.

Example 1.97. event_route[tm:branch-failure:id] usage
Example 1.98. event_route[tm:branch-failure:id] usage
...
request_route {
...
Expand All @@ -3051,7 +3065,7 @@ event_route[tm:branch-failure:myroute] {
The request can still be updated, i.e., changes are possible to R-URI
($ru), destination URI ($du) or the send socket ($fs).

Example 1.98. event_route[tm:local-request] usage
Example 1.99. event_route[tm:local-request] usage
...
event_route [tm:local-request] {
xlog("L_INFO", "Routing locally generated $rm to $ru\n");
Expand All @@ -3064,7 +3078,7 @@ event_route [tm:local-request] {
Executed after the tm module sent a local generated, transaction
stateful response.

Example 1.99. event_route[tm:local-response] usage
Example 1.100. event_route[tm:local-response] usage
...
event_route[tm:local-response] {
xlog("tm:local-response replied locally\n");
Expand Down
21 changes: 19 additions & 2 deletions src/modules/tm/doc/functions.xml
Expand Up @@ -3,10 +3,10 @@
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<section id="tm.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
<sectioninfo>
</sectioninfo>

<title>Functions</title>
<sectioninfo>
</sectioninfo>

<section id="tm.f.t_relay">
<title>
Expand Down Expand Up @@ -1890,4 +1890,21 @@ if($var(ts) == 500) { ... }
</programlisting>
</example>
</section>
<section id="tm.f.t_clean">
<title>
<function>t_clean()</function>
</title>
<para>
Cleans active but very old transactions. Returns true (1). Can be
called from any route.
</para>
<example>
<title><function>t_clean</function> usage</title>
<programlisting>
...
t_clean();
...
</programlisting>
</example>
</section>
</section>
9 changes: 9 additions & 0 deletions src/modules/tm/tm.c
Expand Up @@ -208,6 +208,7 @@ static int w_t_uac_send(sip_msg_t* msg, char* pmethod, char* pruri,
char* pnexthop, char* psock, char *phdrs, char* pbody);
static int w_t_get_status_code(sip_msg_t* msg, char *p1, char *p2);

static int t_clean(struct sip_msg* msg, char* key, char* value);

/* by default the fr timers avps are not set, so that the avps won't be
* searched for nothing each time a new transaction is created */
Expand Down Expand Up @@ -411,6 +412,7 @@ static cmd_export_t cmds[]={
REQUEST_ROUTE | FAILURE_ROUTE},
{"t_next_contact_flow", t_next_contact_flow, 0, 0, 0,
REQUEST_ROUTE },
{"t_clean", t_clean, 0, 0, 0, ANY_ROUTE },

/* not applicable from the script */
{"load_tm", (cmd_function)load_tm, NO_SCRIPT, 0, 0, 0},
Expand Down Expand Up @@ -2952,6 +2954,13 @@ static int ki_t_relay_to_flags(sip_msg_t *msg, int rflags)
return ki_t_relay_to_proxy_flags(msg, NULL, rflags);
}

/* script function to clean active but very old transactions */
static int t_clean(struct sip_msg* msg, char* key, char* value)
{
tm_clean_lifetime();
return 1;
}

/**
*
*/
Expand Down

0 comments on commit 51d95e0

Please sign in to comment.