Module: kamailio
Branch: master
Commit: fc90242ddd046a3cfd545a50cf636454de173d6f
URL:
https://github.com/kamailio/kamailio/commit/fc90242ddd046a3cfd545a50cf63645…
Author: Konstantin Tumalevich <userad(a)gmail.com>
Committer: Konstantin Tumalevich <userad(a)gmail.com>
Date: 2015-11-12T16:58:48+05:00
sipcapture: add async support
- Add support for storing in asynchronous mode if supported
by database backend
---
Modified: modules/sipcapture/README
Modified: modules/sipcapture/doc/sipcapture_admin.xml
Modified: modules/sipcapture/sipcapture.c
---
Diff:
https://github.com/kamailio/kamailio/commit/fc90242ddd046a3cfd545a50cf63645…
Patch:
https://github.com/kamailio/kamailio/commit/fc90242ddd046a3cfd545a50cf63645…
---
diff --git a/modules/sipcapture/README b/modules/sipcapture/README
index 1f9fa2d..bef4af4 100644
--- a/modules/sipcapture/README
+++ b/modules/sipcapture/README
@@ -235,6 +235,10 @@ modparam("sipcapture", "hash_source",
"to_user")
when the DB driver has support for it. If no INSERT DELAYED support is
offered by DB driver, then standard INSERT is used.
+ If set to 2, use ASYNC INSERT to store sip message into capture table
+ when the DB driver has support for it. If no ASYNC INSERT support is
+ offered by DB driver, then standard INSERT is used.
+
Default value is 0 (no INSERT DELAYED).
Example 1.5. db_insert_mode example
diff --git a/modules/sipcapture/doc/sipcapture_admin.xml
b/modules/sipcapture/doc/sipcapture_admin.xml
index 7a835bd..2723acf 100644
--- a/modules/sipcapture/doc/sipcapture_admin.xml
+++ b/modules/sipcapture/doc/sipcapture_admin.xml
@@ -168,6 +168,11 @@ modparam("sipcapture", "hash_source",
"to_user")
is offered by DB driver, then standard INSERT is used.
</para>
<para>
+ If set to 2, use ASYNC INSERT to store sip message into capture table
+ when the DB driver has support for it. If no ASYNC INSERT support is
+ offered by DB driver, then standard INSERT is used.
+ </para>
+ <para>
Default value is 0 (no INSERT DELAYED).
</para>
<example>
diff --git a/modules/sipcapture/sipcapture.c b/modules/sipcapture/sipcapture.c
index 256ddc7..d373de0 100644
--- a/modules/sipcapture/sipcapture.c
+++ b/modules/sipcapture/sipcapture.c
@@ -1491,6 +1491,8 @@ static int sip_capture_store(struct _sipcapture_object *sco, str
*dtable, _captu
if (db_insert_mode == 1 && c->db_funcs.insert_delayed != NULL)
insert = c->db_funcs.insert_delayed;
+ else if (db_insert_mode == 2 && c->db_funcs.insert_async != NULL)
+ insert = c->db_funcs.insert_async;
else
insert = c->db_funcs.insert;
ret = insert(c->db_con, db_keys, db_vals, NR_KEYS);
@@ -2362,6 +2364,11 @@ int receive_logging_json_msg(char * buf, unsigned int len, struct
hep_generic_re
LM_ERR("failed to insert delayed into database\n");
goto error;
}
+ } else if (db_insert_mode==2 && c->db_funcs.insert_async!=NULL) {
+ if (c->db_funcs.insert_async(c->db_con, db_keys, db_vals, RTCP_NR_KEYS) < 0)
{
+ LM_ERR("failed to insert async into database\n");
+ goto error;
+ }
} else if (c->db_funcs.insert(c->db_con, db_keys, db_vals, RTCP_NR_KEYS)
< 0) {
LM_ERR("failed to insert into database\n");
goto error;