nsq: add db_table_lock_type 866/head
authorEmmanuel Schmidbauer <emmanuel@getweave.com>
Tue, 29 Nov 2016 14:10:45 +0000 (09:10 -0500)
committerEmmanuel Schmidbauer <emmanuel@getweave.com>
Tue, 29 Nov 2016 14:10:45 +0000 (09:10 -0500)
modules/nsq/doc/nsq_admin.xml
modules/nsq/nsq_mod.c
modules/nsq/nsq_mod.h
modules/nsq/nsq_pua.c

index 6a1c90f..57fede6 100644 (file)
@@ -437,6 +437,25 @@ modparam("nsq", "db_url", "&defaultdb;")
 ...
 modparam("nsq", "presentity_table", "my_presentity_table")
 ...
+</programlisting>
+                       </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>
index 3dd4b08..61d6334 100644 (file)
@@ -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;
                }
index cd904dd..d86ac36 100644 (file)
@@ -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);
index b5ff38f..badb8cf 100644 (file)
@@ -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;
                }