Module: kamailio
Branch: master
Commit: 17fadef3127901a08daf115fb350c2e59b1fd485
URL:
https://github.com/kamailio/kamailio/commit/17fadef3127901a08daf115fb350c2e…
Author: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Committer: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Date: 2016-11-29T09:10:45-05:00
nsq: add db_table_lock_type
---
Modified: modules/nsq/doc/nsq_admin.xml
Modified: modules/nsq/nsq_mod.c
Modified: modules/nsq/nsq_mod.h
Modified: modules/nsq/nsq_pua.c
---
Diff:
https://github.com/kamailio/kamailio/commit/17fadef3127901a08daf115fb350c2e…
Patch:
https://github.com/kamailio/kamailio/commit/17fadef3127901a08daf115fb350c2e…
---
diff --git a/modules/nsq/doc/nsq_admin.xml b/modules/nsq/doc/nsq_admin.xml
index 6a1c90f..57fede6 100644
--- a/modules/nsq/doc/nsq_admin.xml
+++ b/modules/nsq/doc/nsq_admin.xml
@@ -441,6 +441,25 @@ modparam("nsq", "presentity_table",
"my_presentity_table")
</example>
</section>
+ <section>
+ <title><varname>db_table_lock_type</varname>(int)</title>
+ <para>
+ Enable (=1) or disable (=0) the locks for table during a
+ transaction.
+ </para>
+ <para>
+ <emphasis>Default value is <quote>1</quote>.</emphasis>
+ </para>
+ <example>
+ <title>Set <varname>db_table_lock_type</varname>
parameter</title>
+<programlisting format="linespecific">
+...
+modparam("nsq", "db_table_lock_type", 0)
+...
+</programlisting>
+ </example>
+ </section>
+
</section>
<section>
<title>Functions</title>
diff --git a/modules/nsq/nsq_mod.c b/modules/nsq/nsq_mod.c
index 3dd4b08..61d6334 100644
--- a/modules/nsq/nsq_mod.c
+++ b/modules/nsq/nsq_mod.c
@@ -65,6 +65,7 @@ static param_export_t params[]=
{"db_url", PARAM_STR, &nsq_db_url},
{"pua_mode", INT_PARAM, &dbn_pua_mode},
{"json_escape_char", PARAM_STR, &nsq_json_escape_str},
+ {"db_table_lock_type", INT_PARAM, &db_table_lock_type},
{ 0, 0, 0 }
};
@@ -191,6 +192,10 @@ static int mod_init(void)
return -1;
}
+ if (db_table_lock_type != 1) {
+ db_table_lock = DB_LOCKING_NONE;
+ }
+
nsq_pa_dbf.close(nsq_pa_db);
nsq_pa_db = NULL;
}
diff --git a/modules/nsq/nsq_mod.h b/modules/nsq/nsq_mod.h
index cd904dd..d86ac36 100644
--- a/modules/nsq/nsq_mod.h
+++ b/modules/nsq/nsq_mod.h
@@ -87,6 +87,8 @@ db1_con_t *nsq_pa_db = NULL;
db_func_t nsq_pa_dbf;
str nsq_presentity_table = str_init(PRESENTITY_TABLE);
str nsq_db_url = {NULL, 0};
+int db_table_lock_type = 1;
+db_locking_t db_table_lock = DB_LOCKING_WRITE;
static int mod_init(void);
static int mod_child_init(int);
diff --git a/modules/nsq/nsq_pua.c b/modules/nsq/nsq_pua.c
index b5ff38f..badb8cf 100644
--- a/modules/nsq/nsq_pua.c
+++ b/modules/nsq/nsq_pua.c
@@ -37,6 +37,7 @@
extern db1_con_t *nsq_pa_db;
extern db_func_t nsq_pa_dbf;
+extern db_locking_t db_table_lock;
extern str nsq_presentity_table;
extern str nsq_db_url;
@@ -152,7 +153,7 @@ int nsq_pua_update_presentity(str* event, str* realm, str* user, str*
etag, str*
}
if (nsq_pa_dbf.start_transaction) {
- if (nsq_pa_dbf.start_transaction(nsq_pa_db, DB_LOCKING_WRITE) < 0) {
+ if (nsq_pa_dbf.start_transaction(nsq_pa_db, db_table_lock) < 0) {
LM_ERR("in start_transaction\n");
goto error;
}