Module: sip-router
Branch: master
Commit: d85c6b9037f788971c9f47dc95ad94ea1ea92fd2
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d85c6b9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Mar 27 23:52:49 2012 +0200
siptrace: new parameter to allow the option of doing delayed insert to db
- if 'trace_delayed' parameter is set to 1, insert to database table is
done delayed, when the db server has support for it
---
modules_k/siptrace/README | 30 ++++++++++++++----
modules_k/siptrace/doc/siptrace_admin.xml | 19 ++++++++++++
modules_k/siptrace/siptrace.c | 46 ++++++++++++++++++++++------
3 files changed, 78 insertions(+), 17 deletions(-)
diff --git a/modules_k/siptrace/README b/modules_k/siptrace/README
index 7934f24..a35a9ce 100644
--- a/modules_k/siptrace/README
+++ b/modules_k/siptrace/README
@@ -16,9 +16,9 @@ Daniel-Constantin Mierla
<miconda(a)gmail.com>
- Copyright © 2010
asipto.com
+ Copyright � 2010
asipto.com
- Copyright © 2006 voice-system.ro
+ Copyright � 2006 voice-system.ro
__________________________________________________________________
Table of Contents
@@ -48,6 +48,7 @@ Daniel-Constantin Mierla
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
+ 3.16. trace_delayed (integer)
4. Functions
@@ -77,7 +78,8 @@ Daniel-Constantin Mierla
1.13. Set hep_mode_on parameter
1.14. Set hep_version parameter
1.15. Set hep_capture_id parameter
- 1.16. sip_trace() usage
+ 1.16. Set trace_delayed parameter
+ 1.17. sip_trace() usage
Chapter 1. Admin Guide
@@ -106,6 +108,7 @@ Chapter 1. Admin Guide
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
+ 3.16. trace_delayed (integer)
4. Functions
@@ -174,6 +177,7 @@ Chapter 1. Admin Guide
3.13. hep_mode_on (integer)
3.14. hep_version (integer)
3.15. hep_capture_id (integer)
+ 3.16. trace_delayed (integer)
3.1. db_url (str)
@@ -380,11 +384,23 @@ modparam("siptrace", "hep_version", 2)
modparam("siptrace", "hep_capture_id", 234)
...
+3.16. trace_delayed (integer)
+
+ Use 'INSERT DELAYED' to store to database when it is available, instead
+ of 'INSERT'.
+
+ Default value is 0 (off).
+
+ Example 1.16. Set trace_delayed parameter
+...
+modparam("siptrace", "trace_delayed", 1)
+...
+
4. Functions
4.1. sip_trace()
-4.1. sip_trace()
+4.1. sip_trace()
Store current processed SIP message in database. It is stored in the
form prior applying chages made to it.
@@ -392,7 +408,7 @@ modparam("siptrace", "hep_capture_id", 234)
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
ONREPLY_ROUTE, BRANCH_ROUTE.
- Example 1.16. sip_trace() usage
+ Example 1.17. sip_trace() usage
...
sip_trace();
...
@@ -401,7 +417,7 @@ sip_trace();
5.1. sip_trace
-5.1. sip_trace
+5.1. sip_trace
Name: sip_trace
@@ -410,7 +426,7 @@ sip_trace();
+ on
+ off
The parameter is optional - if missing, the command will return the
- status of the SIP message tracing (as string “on” or “off” )
+ status of the SIP message tracing (as string "on" or "off" )
without changing anything.
MI FIFO Command Format:
diff --git a/modules_k/siptrace/doc/siptrace_admin.xml
b/modules_k/siptrace/doc/siptrace_admin.xml
index e6492e0..0d1e064 100644
--- a/modules_k/siptrace/doc/siptrace_admin.xml
+++ b/modules_k/siptrace/doc/siptrace_admin.xml
@@ -431,6 +431,25 @@ modparam("siptrace", "hep_capture_id", 234)
</programlisting>
</example>
</section>
+ <section>
+ <title><varname>trace_delayed</varname>
(integer)</title>
+ <para>
+ Use 'INSERT DELAYED' to store to database when it is available,
+ instead of 'INSERT'.
+ </para>
+ <para>
+ Default value is <emphasis>0 (off)</emphasis>.
+ </para>
+ <example>
+ <title>Set <varname>trace_delayed</varname>
+ parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("siptrace", "trace_delayed", 1)
+...
+</programlisting>
+ </example>
+ </section>
</section>
diff --git a/modules_k/siptrace/siptrace.c b/modules_k/siptrace/siptrace.c
index b8df1e6..b54d893 100644
--- a/modules_k/siptrace/siptrace.c
+++ b/modules_k/siptrace/siptrace.c
@@ -129,6 +129,7 @@ int trace_on = 0;
int trace_sl_acks = 1;
int trace_to_database = 1;
+int trace_delayed = 0;
int hep_version = 1;
int hep_capture_id = 1;
@@ -198,7 +199,8 @@ static param_export_t params[] = {
{"xheaders_read", INT_PARAM, &xheaders_read },
{"hep_mode_on", INT_PARAM, &hep_mode_on },
{"hep_version", INT_PARAM, &hep_version },
- {"hep_capture_id", INT_PARAM, &hep_capture_id },
+ {"hep_capture_id", INT_PARAM, &hep_capture_id },
+ {"trace_delayed", INT_PARAM, &trace_delayed },
{0, 0, 0}
};
@@ -790,9 +792,17 @@ static int sip_trace_store_db(struct _siptrace_data *sto)
db_vals[9].val.str_val.len = 0;
LM_DBG("storing info...\n");
- if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
- LM_ERR("error storing trace\n");
- goto error;
+ if(trace_delayed!=0 && db_funcs.insert_delayed!=NULL)
+ {
+ if(db_funcs.insert_delayed(db_con, db_keys, db_vals, NR_KEYS)<0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
+ } else {
+ if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
}
#ifdef STATISTICS
update_stat(sto->stat, 1);
@@ -805,9 +815,17 @@ static int sip_trace_store_db(struct _siptrace_data *sto)
db_vals[9].val.str_val = sto->avp_value.s;
LM_DBG("storing info...\n");
- if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
- LM_ERR("error storing trace\n");
- goto error;
+ if(trace_delayed!=0 && db_funcs.insert_delayed!=NULL)
+ {
+ if(db_funcs.insert_delayed(db_con, db_keys, db_vals, NR_KEYS) < 0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
+ } else {
+ if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
}
sto->avp = search_next_avp(&sto->state, &sto->avp_value);
@@ -815,9 +833,17 @@ static int sip_trace_store_db(struct _siptrace_data *sto)
db_vals[9].val.str_val = sto->avp_value.s;
LM_DBG("storing info...\n");
- if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
- LM_ERR("error storing trace\n");
- goto error;
+ if(trace_delayed!=0 && db_funcs.insert_delayed!=NULL)
+ {
+ if(db_funcs.insert_delayed(db_con, db_keys, db_vals, NR_KEYS) < 0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
+ } else {
+ if(db_funcs.insert(db_con, db_keys, db_vals, NR_KEYS) < 0) {
+ LM_ERR("error storing trace\n");
+ goto error;
+ }
}
sto->avp = search_next_avp(&sto->state, &sto->avp_value);
}