Module: sip-router
Branch: master
Commit: aedf75c6a0a0d9253479530b3ad50783f12efd58
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=aedf75c…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Sun May 13 01:13:36 2012 +0100
modules_k/rls: Use non-pooled connections when in DB only mode (where supported)
- This helps with databases (such as PostgreSQL which is the only one that
currently supports specifying non-pooled connections) that create a server
process per client connection.
- Fixed a couple of (end|abort)_transaction cases where dbmode was not checked.
---
modules_k/rls/notify.c | 25 ++++++++++---------------
modules_k/rls/resource_notify.c | 6 +++---
modules_k/rls/rls.c | 24 ++++++++++++++++++++----
3 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/modules_k/rls/notify.c b/modules_k/rls/notify.c
index fd99b5a..82324a9 100644
--- a/modules_k/rls/notify.c
+++ b/modules_k/rls/notify.c
@@ -944,7 +944,7 @@ void rls_notify_callback( struct cell *t, int type, struct tmcb_params
*ps)
db_val_t db_vals[2];
unsigned int hash_code;
subs_t subs;
-
+
memset(&subs, 0, sizeof(subs_t));
subs.to_tag= ((dialog_id_t*)(*ps->param))->to_tag;
@@ -953,9 +953,15 @@ void rls_notify_callback( struct cell *t, int type, struct
tmcb_params *ps)
if (dbmode != RLS_DB_ONLY)
{
- /* delete from database table */
-
+ /* delete from cache table */
+ hash_code= core_hash(&subs.callid, &subs.to_tag , hash_size);
+ if(pres_delete_shtable(rls_table,hash_code, subs.to_tag)< 0)
+ {
+ LM_ERR("record not found in hash table\n");
+ }
+
+ /* delete from database table */
if (rls_dbf.use_table(rls_db, &rlsubs_table) < 0)
{
LM_ERR("in use_table\n");
@@ -976,24 +982,13 @@ void rls_notify_callback( struct cell *t, int type, struct
tmcb_params *ps)
if (rls_dbf.delete(rls_db, db_keys, 0, db_vals, 2) < 0)
LM_ERR("cleaning expired messages\n");
}
-
- /* delete from cache table */
- if (dbmode == RLS_DB_ONLY)
+ else
{
if (delete_rlsdb(&subs.callid, &subs.to_tag, NULL) < 0 )
{
LM_ERR( "unable to delete record from DB\n" );
}
}
- else
- {
- hash_code= core_hash(&subs.callid, &subs.to_tag , hash_size);
-
- if(pres_delete_shtable(rls_table,hash_code, subs.to_tag)< 0)
- {
- LM_ERR("record not found in hash table\n");
- }
- }
}
done:
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index b1da62a..bf9aa0d 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -898,7 +898,7 @@ static void timer_send_full_state_notifies(int round)
goto done;
}
- if (rls_dbf.start_transaction)
+ if (dbmode == RLS_DB_ONLY && rls_dbf.start_transaction)
{
if (rls_dbf.start_transaction(rls_db) < 0)
{
@@ -926,7 +926,7 @@ static void timer_send_full_state_notifies(int round)
goto done;
}
- if (rls_dbf.end_transaction)
+ if (dbmode == RLS_DB_ONLY && rls_dbf.end_transaction)
{
if (rls_dbf.end_transaction(rls_db) < 0)
{
@@ -1011,7 +1011,7 @@ done:
rls_dbf.free_result(rls_db, result);
if (doc != NULL)
xmlFreeDoc(doc);
- if (rls_dbf.abort_transaction)
+ if (dbmode == RLS_DB_ONLY && rls_dbf.abort_transaction)
{
if (rls_dbf.abort_transaction(rls_db) < 0)
LM_ERR("in abort_transaction\n");
diff --git a/modules_k/rls/rls.c b/modules_k/rls/rls.c
index 7e73a27..06de4cb 100644
--- a/modules_k/rls/rls.c
+++ b/modules_k/rls/rls.c
@@ -721,7 +721,11 @@ static int child_init(int rank)
LM_CRIT("database not bound\n");
return -1;
}
- rls_db = rls_dbf.init(&db_url);
+ /* In DB only mode do not pool the connections where possible. */
+ if (dbmode == RLS_DB_ONLY && rls_dbf.init2)
+ rls_db = rls_dbf.init2(&db_url, DB_POOLING_NONE);
+ else
+ rls_db = rls_dbf.init(&db_url);
if (!rls_db)
{
LM_ERR("child %d: Error while connecting database\n",
@@ -744,7 +748,11 @@ static int child_init(int rank)
LM_CRIT("database not bound\n");
return -1;
}
- rlpres_db = rlpres_dbf.init(&rlpres_db_url);
+ /* In DB only mode do not pool the connections where possible. */
+ if (dbmode == RLS_DB_ONLY && rlpres_dbf.init2)
+ rlpres_db = rlpres_dbf.init2(&db_url, DB_POOLING_NONE);
+ else
+ rlpres_db = rlpres_dbf.init(&db_url);
if (!rlpres_db)
{
LM_ERR("child %d: Error while connecting database\n",
@@ -794,7 +802,11 @@ static int mi_child_init(void)
LM_CRIT("database not bound\n");
return -1;
}
- rls_db = rls_dbf.init(&db_url);
+ /* In DB only mode do not pool the connections where possible. */
+ if (dbmode == RLS_DB_ONLY && rls_dbf.init2)
+ rls_db = rls_dbf.init2(&db_url, DB_POOLING_NONE);
+ else
+ rls_db = rls_dbf.init(&db_url);
if (!rls_db)
{
LM_ERR("Error while connecting database\n");
@@ -816,7 +828,11 @@ static int mi_child_init(void)
LM_CRIT("database not bound\n");
return -1;
}
- rlpres_db = rlpres_dbf.init(&rlpres_db_url);
+ /* In DB only mode do not pool the connections where possible. */
+ if (dbmode == RLS_DB_ONLY && rlpres_dbf.init2)
+ rlpres_db = rlpres_dbf.init2(&db_url, DB_POOLING_NONE);
+ else
+ rlpres_db = rlpres_dbf.init(&db_url);
if (!rlpres_db)
{
LM_ERR("Error while connecting database\n");