Browse code

sipcapture: add async support

- Add support for storing in asynchronous mode if supported
by database backend

Konstantin Tumalevich authored on 12/11/2015 11:58:48
Showing 3 changed files
... ...
@@ -235,6 +235,10 @@ modparam("sipcapture", "hash_source", "to_user")
235 235
    when the DB driver has support for it. If no INSERT DELAYED support is
236 236
    offered by DB driver, then standard INSERT is used.
237 237
 
238
+   If set to 2, use ASYNC INSERT to store sip message into capture table
239
+   when the DB driver has support for it. If no ASYNC INSERT support is
240
+   offered by DB driver, then standard INSERT is used.
241
+
238 242
    Default value is 0 (no INSERT DELAYED).
239 243
 
240 244
    Example 1.5. db_insert_mode example
... ...
@@ -168,6 +168,11 @@ modparam("sipcapture", "hash_source", "to_user")
168 168
                 is offered by DB driver, then standard INSERT is used.
169 169
                 </para>
170 170
                 <para>
171
+                If set to 2, use ASYNC INSERT to store sip message into capture table
172
+                when the DB driver has support for it. If no ASYNC INSERT support is
173
+                offered by DB driver, then standard INSERT is used.
174
+                </para>
175
+                <para>
171 176
                 Default value is 0 (no INSERT DELAYED).
172 177
                 </para>
173 178
                 <example>
... ...
@@ -1491,6 +1491,8 @@ static int sip_capture_store(struct _sipcapture_object *sco, str *dtable, _captu
1491 1491
 
1492 1492
 	if (db_insert_mode == 1 && c->db_funcs.insert_delayed != NULL)
1493 1493
 		insert = c->db_funcs.insert_delayed;
1494
+	else if (db_insert_mode == 2 && c->db_funcs.insert_async != NULL)
1495
+		insert = c->db_funcs.insert_async;
1494 1496
 	else
1495 1497
 		insert = c->db_funcs.insert;
1496 1498
 	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
2362 2364
                 	LM_ERR("failed to insert delayed into database\n");
2363 2365
                         goto error;
2364 2366
                 }
2367
+	} else if (db_insert_mode==2 && c->db_funcs.insert_async!=NULL) {
2368
+		if (c->db_funcs.insert_async(c->db_con, db_keys, db_vals, RTCP_NR_KEYS) < 0) {
2369
+			LM_ERR("failed to insert async into database\n");
2370
+			goto error;
2371
+		}
2365 2372
         } else if (c->db_funcs.insert(c->db_con, db_keys, db_vals, RTCP_NR_KEYS) < 0) {
2366 2373
 		LM_ERR("failed to insert into database\n");
2367 2374
                 goto error;