[sr-dev] git:master: htable: use mode everywhere to control the locks for add operation

Daniel-Constantin Mierla miconda at gmail.com
Sat Nov 8 11:28:23 CET 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Nov  6 18:43:50 2014 +0100

htable: use mode everywhere to control the locks for add operation

---

 modules/htable/ht_api.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/htable/ht_api.c b/modules/htable/ht_api.c
index 13d373d..55f1f3a 100644
--- a/modules/htable/ht_api.c
+++ b/modules/htable/ht_api.c
@@ -606,7 +606,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 					if(it->next)
 						it->next->prev = it->prev;
 					ht->entries[idx].esize--;
-					lock_release(&ht->entries[idx].lock);
+					if(mode) lock_release(&ht->entries[idx].lock);
 					ht_cell_free(it);
 					return NULL;
 				}
@@ -625,7 +625,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 					if(old->msize>=it->msize)
 					{
 						memcpy(old, it, it->msize);
-						lock_release(&ht->entries[idx].lock);
+						if(mode) lock_release(&ht->entries[idx].lock);
 						return old;
 					}
 				}
@@ -673,7 +673,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode,
 		if(old->msize>=it->msize)
 		{
 			memcpy(old, it, it->msize);
-			lock_release(&ht->entries[idx].lock);
+			if(mode) lock_release(&ht->entries[idx].lock);
 			return old;
 		}
 	}




More information about the sr-dev mailing list