浏览代码

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.
Richard Good 10 年之前
父节点
当前提交
1de57a47c3
共有 4 个文件被更改,包括 38 次插入6 次删除
  1. 22 0
      modules/pua/doc/pua_admin.xml
  2. 8 1
      modules/pua/pua.c
  3. 4 2
      modules/pua/send_publish.c
  4. 4 3
      modules/pua/send_subscribe.c

+ 22 - 0
modules/pua/doc/pua_admin.xml

@@ -286,6 +286,28 @@ modparam("pua", "db_mode", 0)
 </programlisting>
 		</example>
 	</section>
+	<section>
+	    <title><varname>db_table_lock_write</varname> (integer)</title>
+	    <para>
+		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.
+	    </para>
+	    <para>
+		<emphasis>
+		    Default value is 1 (Write Lock for the Tables).
+		</emphasis>
+	    </para>
+	    <example>
+		<title>Set <varname>db_table_lock_write</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("pua", "db_table_lock_write", 0)
+...
+</programlisting>
+	    </example>
+	</section>
+	
 	<section>
 		<title><varname>check_remote_contact</varname> (int)</title>
 		<para>

+ 8 - 1
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;
 }
 

+ 4 - 2
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;

+ 4 - 3
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 @@ faked_error:
 
 		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;