[sr-dev] git:4.3:b839aa86: tsilo: lock before linking var to the entry in slot

Daniel-Constantin Mierla miconda at gmail.com
Mon Mar 14 11:49:14 CET 2016


Module: kamailio
Branch: 4.3
Commit: b839aa8630ec34b312d743175f87496f6e920352
URL: https://github.com/kamailio/kamailio/commit/b839aa8630ec34b312d743175f87496f6e920352

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-03-14T11:48:40+01:00

tsilo: lock before linking var to the entry in slot

- entry points to the address of first entry, which can be updated
  before aquiring the lock

(cherry picked from commit 8ae2713477027a229ae4ee7045557151e467aff3)
(cherry picked from commit 84d73b950f3ec13fe5f5345a4440d0909e30fff4)

---

Modified: modules/tsilo/ts_rpc.c

---

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

---

diff --git a/modules/tsilo/ts_rpc.c b/modules/tsilo/ts_rpc.c
index 20783f4..7a3b659 100644
--- a/modules/tsilo/ts_rpc.c
+++ b/modules/tsilo/ts_rpc.c
@@ -45,6 +45,9 @@ static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_trans
 {
 	void* vh;
 
+	if(t==NULL)
+		return -1;
+
 	if(rpc->struct_add(ih, "{", "Transaction", &vh)<0)
 	{
 		rpc->fault(ctx, 500, "Internal error creating transaction struct");
@@ -73,9 +76,9 @@ static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_trans
  */
 static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 {
-	ts_transaction_t* trans;
-	struct ts_urecord* record;
-	struct ts_entry* entry;
+	ts_transaction_t* trans = NULL;
+	struct ts_urecord* record = NULL;
+	struct ts_entry* entry = NULL;
 
 	str brief = {0, 0};
 
@@ -115,8 +118,8 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 
 	/* add the entries per hash */
 	for(i=0,n=0,max=0,ntrans=0; i<t_table->size; i++) {
+		lock_entry(&t_table->entries[i]);
 		entry = &t_table->entries[i];
-		lock_entry(entry);
 
 		n += entry->n;
 		if(max<entry->n)
@@ -130,7 +133,7 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 					"Hash", record->rurihash,
 					"Transactions", &ih)<0)
 				{
-					unlock_entry(entry);
+					unlock_entry(&t_table->entries[i]);
 					rpc->fault(c, 500, "Internal error creating ruri struct");
 					return;
 				}
@@ -139,13 +142,13 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 				ntrans += 1;
 				if (short_dump==0) {
 					if (rpc_dump_transaction(rpc, c, ih, trans) == -1) {
-						unlock_entry(entry);
+						unlock_entry(&t_table->entries[i]);
 						return;
 					}
 				}
 			}
 		}
-		unlock_entry(entry);
+		unlock_entry(&t_table->entries[i]);
 	}
 
 	/* extra attributes node */




More information about the sr-dev mailing list