Browse code

modukles/tm: added t_clean() script function

Juha Heinanen authored on 06/03/2020 07:08:12
Showing 3 changed files
... ...
@@ -135,6 +135,7 @@ Daniel-Constantin Mierla
135 135
                       body)
136 136
 
137 137
               4.54. t_get_status_code()
138
+              4.55. t_clean()
138 139
 
139 140
         5. RPC Commands
140 141
 
... ...
@@ -270,9 +271,10 @@ Daniel-Constantin Mierla
270 271
    1.94. t_is_retr_async_reply usage
271 272
    1.95. t_uac_send usage
272 273
    1.96. t_get_status_code usage
273
-   1.97. event_route[tm:branch-failure:id] usage
274
-   1.98. event_route[tm:local-request] usage
275
-   1.99. event_route[tm:local-response] usage
274
+   1.97. t_clean usage
275
+   1.98. event_route[tm:branch-failure:id] usage
276
+   1.99. event_route[tm:local-request] usage
277
+   1.100. event_route[tm:local-response] usage
276 278
 
277 279
 Chapter 1. Admin Guide
278 280
 
... ...
@@ -388,6 +390,7 @@ Chapter 1. Admin Guide
388 390
         4.52. t_is_retr_async_reply()
389 391
         4.53. t_uac_send(method, ruri, nexthop, socket, headers, body)
390 392
         4.54. t_get_status_code()
393
+        4.55. t_clean()
391 394
 
392 395
    5. RPC Commands
393 396
 
... ...
@@ -1740,6 +1743,7 @@ modparam("tm", "rich_redirect", 3)
1740 1743
    4.52. t_is_retr_async_reply()
1741 1744
    4.53. t_uac_send(method, ruri, nexthop, socket, headers, body)
1742 1745
    4.54. t_get_status_code()
1746
+   4.55. t_clean()
1743 1747
 
1744 1748
 4.1.  t_relay([host, port])
1745 1749
 
... ...
@@ -2912,6 +2916,16 @@ $var(ts) = t_get_status_code();
2912 2916
 if($var(ts) == 500) { ... }
2913 2917
 ...
2914 2918
 
2919
+4.55.  t_clean()
2920
+
2921
+   Cleans active but very old transactions. Returns true (1). Can be
2922
+   called from any route.
2923
+
2924
+   Example 1.97. t_clean usage
2925
+...
2926
+t_clean();
2927
+...
2928
+
2915 2929
 5. RPC Commands
2916 2930
 
2917 2931
    5.1. tm.list
... ...
@@ -3025,7 +3039,7 @@ if($var(ts) == 500) { ... }
3025 3039
    enabled with the t_on_branch_failure function. This event_route uses
3026 3040
    the BRANCH_FAILURE_ROUTE route type.
3027 3041
 
3028
-   Example 1.97. event_route[tm:branch-failure:id] usage
3042
+   Example 1.98. event_route[tm:branch-failure:id] usage
3029 3043
 ...
3030 3044
 request_route {
3031 3045
     ...
... ...
@@ -3051,7 +3065,7 @@ event_route[tm:branch-failure:myroute] {
3051 3065
    The request can still be updated, i.e., changes are possible to R-URI
3052 3066
    ($ru), destination URI ($du) or the send socket ($fs).
3053 3067
 
3054
-   Example 1.98. event_route[tm:local-request] usage
3068
+   Example 1.99. event_route[tm:local-request] usage
3055 3069
 ...
3056 3070
 event_route [tm:local-request] {
3057 3071
     xlog("L_INFO", "Routing locally generated $rm to $ru\n");
... ...
@@ -3064,7 +3078,7 @@ event_route [tm:local-request] {
3064 3078
    Executed after the tm module sent a local generated, transaction
3065 3079
    stateful response.
3066 3080
 
3067
-   Example 1.99. event_route[tm:local-response] usage
3081
+   Example 1.100. event_route[tm:local-response] usage
3068 3082
 ...
3069 3083
 event_route[tm:local-response] {
3070 3084
     xlog("tm:local-response replied locally\n");
... ...
@@ -3,10 +3,10 @@
3 3
    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 4
 
5 5
 <section id="tm.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
6
-    <sectioninfo>
7
-    </sectioninfo>
8 6
 
9 7
     <title>Functions</title>
8
+    <sectioninfo>
9
+    </sectioninfo>
10 10
 
11 11
     <section id="tm.f.t_relay">
12 12
 	<title>
... ...
@@ -1890,4 +1890,21 @@ if($var(ts) == 500) { ... }
1890 1890
 	    </programlisting>
1891 1891
 	</example>
1892 1892
     </section>
1893
+	<section id="tm.f.t_clean">
1894
+	<title>
1895
+	    <function>t_clean()</function>
1896
+	</title>
1897
+	<para>
1898
+	Cleans active but very old transactions.  Returns true (1).  Can be
1899
+    called from any route.
1900
+	</para>
1901
+	<example>
1902
+	    <title><function>t_clean</function> usage</title>
1903
+	    <programlisting>
1904
+...
1905
+t_clean();
1906
+...
1907
+	    </programlisting>
1908
+	</example>
1893 1909
     </section>
1910
+  </section>
... ...
@@ -208,6 +208,7 @@ static int w_t_uac_send(sip_msg_t* msg, char* pmethod, char* pruri,
208 208
 		char* pnexthop, char* psock, char *phdrs, char* pbody);
209 209
 static int w_t_get_status_code(sip_msg_t* msg, char *p1, char *p2);
210 210
 
211
+static int t_clean(struct sip_msg* msg, char* key, char* value);
211 212
 
212 213
 /* by default the fr timers avps are not set, so that the avps won't be
213 214
  * searched for nothing each time a new transaction is created */
... ...
@@ -411,6 +412,7 @@ static cmd_export_t cmds[]={
411 412
 		REQUEST_ROUTE | FAILURE_ROUTE},
412 413
 	{"t_next_contact_flow", t_next_contact_flow,            0, 0, 0,
413 414
 		REQUEST_ROUTE },
415
+	{"t_clean", t_clean, 0, 0, 0, ANY_ROUTE },
414 416
 
415 417
 	/* not applicable from the script */
416 418
 	{"load_tm",            (cmd_function)load_tm,           NO_SCRIPT,   0, 0, 0},
... ...
@@ -2952,6 +2954,13 @@ static int ki_t_relay_to_flags(sip_msg_t *msg, int rflags)
2952 2954
 	return ki_t_relay_to_proxy_flags(msg, NULL, rflags);
2953 2955
 }
2954 2956
 
2957
+/* script function to clean active but very old transactions */
2958
+static int t_clean(struct sip_msg* msg, char* key, char* value)
2959
+{
2960
+	tm_clean_lifetime();
2961
+	return 1;
2962
+}
2963
+
2955 2964
 /**
2956 2965
  *
2957 2966
  */