Selaa lähdekoodia

Merge pull request #397 from UserAd/master

sipcapture: add async support
Alexandr Dubovikov 10 vuotta sitten
vanhempi
commit
0f55ff0351

+ 4 - 0
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

+ 5 - 0
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>

+ 7 - 0
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;