From 1de57a47c3a26b860785cf2efc2a558d1e65f911 Mon Sep 17 00:00:00 2001 From: Richard Good Date: Tue, 20 Jan 2015 10:46:56 +0200 Subject: [PATCH] modules/pua: new parameter db_table_lock_write New parameter db_table_lock_write: enable (=1) or disable (=0) the locks for table during an transaction. --- modules/pua/doc/pua_admin.xml | 22 ++++++++++++++++++++++ modules/pua/pua.c | 9 ++++++++- modules/pua/send_publish.c | 6 ++++-- modules/pua/send_subscribe.c | 7 ++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/modules/pua/doc/pua_admin.xml b/modules/pua/doc/pua_admin.xml index e7b242db93e..7bb9cbbe5d1 100644 --- a/modules/pua/doc/pua_admin.xml +++ b/modules/pua/doc/pua_admin.xml @@ -286,6 +286,28 @@ modparam("pua", "db_mode", 0) +
+ <varname>db_table_lock_write</varname> (integer) + + Enable (=1) or disable (=0) the Locks for table during an transaction. + Locking only the "current" table causes problems with a MySQL-Databases + in "DB-Only" mode. + + + + Default value is 1 (Write Lock for the Tables). + + + + Set <varname>db_table_lock_write</varname> parameter + +... +modparam("pua", "db_table_lock_write", 0) +... + + +
+
<varname>check_remote_contact</varname> (int) diff --git a/modules/pua/pua.c b/modules/pua/pua.c index e44a38dcdc7..89b0a4906b7 100644 --- a/modules/pua/pua.c +++ b/modules/pua/pua.c @@ -73,6 +73,9 @@ int reginfo_increase_version = 0; pua_event_t* pua_evlist= NULL; int dbmode = 0; +int db_table_lock_write = 1; +db_locking_t db_table_lock = DB_LOCKING_WRITE; + int pua_fetch_rows = 500; /* database connection */ @@ -134,6 +137,7 @@ static param_export_t params[]={ {"check_remote_contact", INT_PARAM, &check_remote_contact}, {"db_mode", INT_PARAM, &dbmode}, {"fetch_rows", INT_PARAM, &pua_fetch_rows}, + {"db_table_lock_write", INT_PARAM, &db_table_lock_write}, {0, 0, 0} }; @@ -280,10 +284,13 @@ static int mod_init(void) register_timer(db_update, 0, update_period); } + if (db_table_lock_write != 1) + db_table_lock = DB_LOCKING_NONE; + if(pua_db) pua_dbf.close(pua_db); pua_db = NULL; - + return 0; } diff --git a/modules/pua/send_publish.c b/modules/pua/send_publish.c index c04163e262f..8cd553b0374 100644 --- a/modules/pua/send_publish.c +++ b/modules/pua/send_publish.c @@ -49,6 +49,8 @@ #include "event_list.h" #include "pua_db.h" +extern db_locking_t db_table_lock; + str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag, str* extra_headers, int is_body) { @@ -216,7 +218,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps) if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction) { - if (pua_dbf.start_transaction(pua_db, DB_LOCKING_WRITE) < 0) + if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0) { LM_ERR("in start_transaction\n"); goto error; @@ -502,7 +504,7 @@ int send_publish( publ_info_t* publ ) if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction) { - if (pua_dbf.start_transaction(pua_db, DB_LOCKING_WRITE) < 0) + if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0) { LM_ERR("in start_transaction\n"); goto error; diff --git a/modules/pua/send_subscribe.c b/modules/pua/send_subscribe.c index 17a4f3fac98..67aa9d2b75d 100644 --- a/modules/pua/send_subscribe.c +++ b/modules/pua/send_subscribe.c @@ -48,6 +48,7 @@ #include "pua_db.h" #include "../presence/subscribe.h" +extern db_locking_t db_table_lock; void print_subs(subs_info_t* subs) { @@ -301,7 +302,7 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *ps) if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction) { - if (pua_dbf.start_transaction(pua_db, DB_LOCKING_WRITE) < 0) + if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0) { LM_ERR("in start_transaction\n"); goto error; @@ -687,7 +688,7 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *ps) if (pua_dbf.start_transaction) { - if (pua_dbf.start_transaction(pua_db, DB_LOCKING_WRITE) < 0) + if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0) { LM_ERR("in start_transaction\n"); goto error; @@ -986,7 +987,7 @@ int send_subscribe(subs_info_t* subs) if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction) { - if (pua_dbf.start_transaction(pua_db, DB_LOCKING_WRITE) < 0) + if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0) { LM_ERR("in start_transaction\n"); goto error;