[sr-dev] git:master: modules_k/rls: Updated to use new (start|end|abort) _transaction DB APIs instead of the original db_(begin|commit|rollback)

Peter Dunkley peter.dunkley at crocodile-rcs.com
Tue Apr 24 11:59:12 CEST 2012


Module: sip-router
Branch: master
Commit: 167714254cca8cb911f2911ba557744ecd6d0d73
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=167714254cca8cb911f2911ba557744ecd6d0d73

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Tue Apr 24 10:58:22 2012 +0100

modules_k/rls: Updated to use new (start|end|abort)_transaction DB APIs instead of the original db_(begin|commit|rollback)

---

 modules_k/rls/notify.c          |   19 ++++++++++-----
 modules_k/rls/resource_notify.c |   47 +++++++++++++++++++++++++-------------
 modules_k/rls/rls_db.c          |   26 ++++++++++++---------
 3 files changed, 58 insertions(+), 34 deletions(-)

diff --git a/modules_k/rls/notify.c b/modules_k/rls/notify.c
index fbb7e17..1e06d57 100644
--- a/modules_k/rls/notify.c
+++ b/modules_k/rls/notify.c
@@ -128,11 +128,11 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
 		goto error;
 	}
 
-	if (dbmode == RLS_DB_ONLY)
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.start_transaction)
 	{
-		if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+		if (rlpres_dbf.start_transaction(rlpres_db) < 0)
 		{
-			LM_ERR("in BEGIN\n");
+			LM_ERR("in start_transaction\n");
 			goto error;
 		}
 	}
@@ -266,11 +266,11 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
 		goto error;
 	}
 
-	if (dbmode == RLS_DB_ONLY)
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.end_transaction)
 	{
-		if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+		if (rlpres_dbf.end_transaction(rlpres_db) < 0)
 		{
-			LM_ERR("in COMMIT\n");
+			LM_ERR("in end_transaction\n");
 			goto error;
 		}
 	}
@@ -289,7 +289,6 @@ int send_full_notify(subs_t* subs, xmlNodePtr rl_node, str* rl_uri,
 
 	return 0;
 error:
-
 	if(rlmi_cont)
 	{
 		if(rlmi_cont->s)
@@ -308,6 +307,12 @@ error:
 		rlpres_dbf.free_result(rlpres_db, result);
 	if(rlsubs_did.s)
 		pkg_free(rlsubs_did.s);
+
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.abort_transaction)
+	{
+		if (rlpres_dbf.abort_transaction(rlpres_db) < 0)
+			LM_ERR("in abort_transaction");
+	}
 	return -1;
 }
 
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index 910b098..310b0af 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -893,10 +893,13 @@ static void timer_send_full_state_notifies(int round)
 		goto done;
 	}
 
-	if (db_begin(&rls_dbf, rls_db) < 0)
+	if (rls_dbf.start_transaction)
 	{
-		LM_ERR("in BEGIN\n");
-		goto done;
+		if (rls_dbf.start_transaction(rls_db) < 0)
+		{
+			LM_ERR("in start_transaction\n");
+			goto done;
+		}
 	}
 
 	/* Step 1: Find rls_watchers that require full-state notification */
@@ -918,10 +921,13 @@ static void timer_send_full_state_notifies(int round)
 		goto done;
 	}
 
-	if (db_commit(&rls_dbf, rls_db) < 0)
+	if (rls_dbf.end_transaction)
 	{
-		LM_ERR("in COMMIT\n");
-		goto done;
+		if (rls_dbf.end_transaction(rls_db) < 0)
+		{
+			LM_ERR("in end_transaction\n");
+			goto done;
+		}
 	}
 
 	/* Step 3: Full-state notify each watcher we found */
@@ -1000,6 +1006,11 @@ done:
 		rls_dbf.free_result(rls_db, result);
 	if (doc != NULL)
 		xmlFreeDoc(doc);
+	if (rls_dbf.abort_transaction)
+	{
+		if (rls_dbf.abort_transaction(rls_db) < 0)
+			LM_ERR("in abort_transaction\n");
+	}
 }
 
 static void timer_send_update_notifies(int round)
@@ -1037,12 +1048,12 @@ static void timer_send_update_notifies(int round)
 		goto done;
 	}
 
-	if (dbmode == RLS_DB_ONLY)
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.start_transaction)
 	{
-		if (db_begin(&rlpres_dbf, rlpres_db) < 0)
+		if (rlpres_dbf.start_transaction(rlpres_db) < 0)
 		{
-			LM_ERR("in BEGIN\n");
-			goto error;
+			LM_ERR("in start_transaction\n");
+			goto done;
 		}
 	}
 
@@ -1060,25 +1071,29 @@ static void timer_send_update_notifies(int round)
 					update_vals, 1, 1)< 0)
 	{
 		LM_ERR("in sql update\n");
-		goto error;
+		goto done;
 	}
 
-	if (dbmode == RLS_DB_ONLY)
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.end_transaction)
 	{
-		if (db_commit(&rlpres_dbf, rlpres_db) < 0)
+		if (rlpres_dbf.end_transaction(rlpres_db) < 0)
 		{
-			LM_ERR("in COMMIT\n");
-			goto error;
+			LM_ERR("in end_transaction\n");
+			goto done;
 		}
 	}
 
 	send_notifies(result, did_col, resource_uri_col, auth_state_col, reason_col,
                   pres_state_col, content_type_col);
-error:
 done:
 	if(result)
 		rlpres_dbf.free_result(rlpres_db, result);
 
+	if (dbmode == RLS_DB_ONLY && rls_dbf.abort_transaction)
+	{
+		if (rlpres_dbf.abort_transaction(rlpres_db) < 0)
+			LM_ERR("in abort_transaction\n");
+	}
 }
 
 void timer_send_notify(unsigned int ticks,void *param)
diff --git a/modules_k/rls/rls_db.c b/modules_k/rls/rls_db.c
index 46bda91..0aab750 100644
--- a/modules_k/rls/rls_db.c
+++ b/modules_k/rls/rls_db.c
@@ -124,7 +124,6 @@ int delete_expired_subs_rlsdb( void )
 	int i;
 	subs_t subs;
 	str rlsubs_did = {0, 0};
-	int transaction_started = 0;
 
 	if(rls_db == NULL)
 	{
@@ -149,12 +148,14 @@ int delete_expired_subs_rlsdb( void )
 	result_cols[r_to_tag_col=n_result_cols++] = &str_to_tag_col;
 	result_cols[r_from_tag_col=n_result_cols++] = &str_from_tag_col;
 
-	if (db_begin(&rls_dbf, rls_db) < 0)
+	if (rls_dbf.start_transaction)
 	{
-		LM_ERR("in BEGIN\n");
-		goto error;
+		if (rls_dbf.start_transaction(rls_db) < 0)
+		{
+			LM_ERR("in start_transaction\n");
+			goto error;
+		}
 	}
-	transaction_started = 1;
 
 	if(rls_dbf.query(rls_db, query_cols, query_ops, query_vals, result_cols, 
 				n_query_cols, n_result_cols, 0, &result )< 0)
@@ -221,10 +222,13 @@ int delete_expired_subs_rlsdb( void )
 		pkg_free(rlsubs_did.s);
 	}
 
-	if (db_commit(&rls_dbf, rls_db) < 0)
+	if (rls_dbf.end_transaction)
 	{
-		LM_ERR("in COMMIT\n");
-		goto error;
+		if (rls_dbf.end_transaction(rls_db) < 0)
+		{
+			LM_ERR("in end_transaction\n");
+			goto error;
+		}
 	}
 
 	if(result) rls_dbf.free_result(rls_db, result);
@@ -234,10 +238,10 @@ error:
 	if (result) rls_dbf.free_result(rls_db, result);
 	if (rlsubs_did.s) pkg_free(rlsubs_did.s);
 
-	if (transaction_started)
+	if (rls_dbf.abort_transaction)
 	{
-		if (db_commit(&rls_dbf, rls_db) < 0)
-			LM_ERR("in COMMIT\n");
+		if (rls_dbf.abort_transaction(rls_db) < 0)
+			LM_ERR("in abort_transaction\n");
 	}
 
 	return -1;




More information about the sr-dev mailing list