Prechádzať zdrojové kódy

Merge pull request #397 from UserAd/master

sipcapture: add async support
Alexandr Dubovikov 10 rokov pred
rodič
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
    when the DB driver has support for it. If no INSERT DELAYED support is
    offered by DB driver, then standard INSERT is used.
    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).
    Default value is 0 (no INSERT DELAYED).
 
 
    Example 1.5. db_insert_mode example
    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.
                 is offered by DB driver, then standard INSERT is used.
                 </para>
                 </para>
                 <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).
                 Default value is 0 (no INSERT DELAYED).
                 </para>
                 </para>
                 <example>
                 <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)
 	if (db_insert_mode == 1 && c->db_funcs.insert_delayed != NULL)
 		insert = c->db_funcs.insert_delayed;
 		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
 	else
 		insert = c->db_funcs.insert;
 		insert = c->db_funcs.insert;
 	ret = insert(c->db_con, db_keys, db_vals, NR_KEYS);
 	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");
                 	LM_ERR("failed to insert delayed into database\n");
                         goto error;
                         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) {
         } 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");
 		LM_ERR("failed to insert into database\n");
                 goto error;               
                 goto error;