[sr-dev] git:5.0:41392baa: tsilo: coherent locking in ts_append

Federico Cabiddu federico.cabiddu at gmail.com
Mon Jul 24 15:17:14 CEST 2017


Module: kamailio
Branch: 5.0
Commit: 41392baa1b9d40e2d5cff5e532b2fe3b6c132bb6
URL: https://github.com/kamailio/kamailio/commit/41392baa1b9d40e2d5cff5e532b2fe3b6c132bb6

Author: Federico Cabiddu <federico.cabiddu at gmail.com>
Committer: Federico Cabiddu <federico.cabiddu at gmail.com>
Date: 2017-07-24T15:18:35+02:00

tsilo: coherent locking in ts_append

(cherry picked from commit 34265457e7c09b56dec295b753fd8250ef8b0c41)

---

Modified: src/modules/tsilo/ts_append.c

---

Diff:  https://github.com/kamailio/kamailio/commit/41392baa1b9d40e2d5cff5e532b2fe3b6c132bb6.diff
Patch: https://github.com/kamailio/kamailio/commit/41392baa1b9d40e2d5cff5e532b2fe3b6c132bb6.patch

---

diff --git a/src/modules/tsilo/ts_append.c b/src/modules/tsilo/ts_append.c
index e6e27e40cc..7d951865f0 100644
--- a/src/modules/tsilo/ts_append.c
+++ b/src/modules/tsilo/ts_append.c
@@ -45,32 +45,31 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 
 	int res;
 	int appended;
-
-	lock_entry_by_ruri(ruri);
-
+	
 	if (use_domain) {
 		t_uri = ruri;
 	} else {
 		if(parse_uri(ruri->s, ruri->len, &p_uri)<0) {
 			LM_ERR("failed to parse uri %.*s\n", ruri->len, ruri->s);
-			unlock_entry_by_ruri(ruri);
 			return -1;
 		}
 		t_uri = &p_uri.user;
 	}
 
+	lock_entry_by_ruri(t_uri);
+
 	res = get_ts_urecord(t_uri, &_r);
 
 	if (res != 0) {
-		LM_ERR("failed to retrieve record for %.*s\n", ruri->len, ruri->s);
-		unlock_entry_by_ruri(ruri);
+		LM_ERR("failed to retrieve record for %.*s\n", t_uri->len, t_uri->s);
+		unlock_entry_by_ruri(t_uri);
 		return -1;
 	}
 
 	ptr = _r->transactions;
 
 	while(ptr) {
-		LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, ruri->len, ruri->s);
+		LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s);
 
 		appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri);
 		if (appended > 0)
@@ -78,7 +77,7 @@ int ts_append(struct sip_msg* msg, str *ruri, char *table) {
 		ptr = ptr->next;
 	}
 
-	unlock_entry_by_ruri(ruri);
+	unlock_entry_by_ruri(t_uri);
 
 	return 1;
 }




More information about the sr-dev mailing list