[sr-dev] git:3.3: modules_k/rls: Added DB transaction code around rls_presentity insert/replace

Peter Dunkley peter.dunkley at crocodile-rcs.com
Mon Aug 13 16:52:47 CEST 2012


Module: sip-router
Branch: 3.3
Commit: 03f8f4d9c4304ac0a8f629e1c94230ab70b58917
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=03f8f4d9c4304ac0a8f629e1c94230ab70b58917

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Mon Aug 13 15:50:05 2012 +0100

modules_k/rls: Added DB transaction code around rls_presentity insert/replace
(cherry picked from commit 65dcb2d0e72757d51b0ee51c457c5440278444bc)

---

 modules_k/rls/resource_notify.c |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index bf9aa0d..8937131 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -767,6 +767,15 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2)
 		goto error;
 	}
 
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.start_transaction)
+	{
+		if (rlpres_dbf.start_transaction(rlpres_db) < 0)
+		{
+			LM_ERR("in start_transaction\n");
+			goto error;
+		}
+	}
+
 	if (rlpres_dbf.replace != NULL)
 	{
 		if(rlpres_dbf.replace(rlpres_db, query_cols, query_vals, n_query_cols,
@@ -796,7 +805,16 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2)
 			LM_DBG("Inserted in database table new record\n");
 		}
 	}
-		
+
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.end_transaction)
+	{
+		if (rlpres_dbf.end_transaction(rlpres_db) < 0)
+		{
+			LM_ERR("in end_transaction\n");
+			goto error;
+		}
+	}
+
 	LM_DBG("Updated rlpres_table\n");	
 	/* reply 200OK */
 done:
@@ -831,6 +849,13 @@ error:
 	if (reason.s) pkg_free(reason.s);
 
 	free_to_params(&TO);
+
+	if (dbmode == RLS_DB_ONLY && rlpres_dbf.abort_transaction)
+	{
+		if (rlpres_dbf.abort_transaction(rlpres_db) < 0)
+			LM_ERR("in abort_transaction\n");
+	}
+
 	return -1;
 }
 




More information about the sr-dev mailing list