[svn-commits] murf: branch murf/datastructs r72435 - in /team/murf/datastructs: include/ast...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 28 08:51:21 CDT 2007


Author: murf
Date: Thu Jun 28 08:51:21 2007
New Revision: 72435

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72435
Log:
Added user-controlled locking to hashtab

Modified:
    team/murf/datastructs/include/asterisk/hashtab.h
    team/murf/datastructs/main/hashtab.c

Modified: team/murf/datastructs/include/asterisk/hashtab.h
URL: http://svn.digium.com/view/asterisk/team/murf/datastructs/include/asterisk/hashtab.h?view=diff&rev=72435&r1=72434&r2=72435
==============================================================================
--- team/murf/datastructs/include/asterisk/hashtab.h (original)
+++ team/murf/datastructs/include/asterisk/hashtab.h Thu Jun 28 08:51:21 2007
@@ -236,5 +236,14 @@
 /* ------------------ */
 /* ------------------ */
 
+/* user-controlled hashtab locking. Create a hashtab without locking, then call the
+   following locking routines yourself to lock the table between threads. */
+
+void ast_hashtab_initlock(struct ast_hashtab *tab); /* call this after you create the table to init the lock */
+void ast_hashtab_wrlock(struct ast_hashtab *tab); /* request a write-lock on the  table. */
+void ast_hashtab_rdlock(struct ast_hashtab *tab); /* request a read-lock on the table-- don't change anything! */
+void ast_hashtab_unlock(struct ast_hashtab *tab);      /* release a read- or write- lock. */
+void ast_hashtab_destroylock(struct ast_hashtab *tab); /* call this before you destroy the table. */
+
 
 #endif

Modified: team/murf/datastructs/main/hashtab.c
URL: http://svn.digium.com/view/asterisk/team/murf/datastructs/main/hashtab.c?view=diff&rev=72435&r1=72434&r2=72435
==============================================================================
--- team/murf/datastructs/main/hashtab.c (original)
+++ team/murf/datastructs/main/hashtab.c Thu Jun 28 08:51:21 2007
@@ -273,6 +273,35 @@
 	}
 }
 
+/* user-controlled hashtab locking. Create a hashtab without locking, then call the
+   following locking routines yourself to lock the table between threads. */
+
+void ast_hashtab_wrlock(struct ast_hashtab *tab)
+{
+	ast_rwlock_wrlock(&tab->lock);
+}
+
+void ast_hashtab_rdlock(struct ast_hashtab *tab)
+{
+	ast_rwlock_rdlock(&tab->lock);
+}
+
+void ast_hashtab_initlock(struct ast_hashtab *tab)
+{
+	ast_rwlock_init(&tab->lock);
+}
+
+void ast_hashtab_destroylock(struct ast_hashtab *tab)
+{
+	ast_rwlock_destroy(&tab->lock);
+}
+
+void ast_hashtab_unlock(struct ast_hashtab *tab)
+{
+	ast_rwlock_unlock(&tab->lock);
+}
+
+
 void ast_hashtab_destroy( struct ast_hashtab *tab)
 {
 	/* this func will free the hash table and all its memory. It
@@ -392,7 +421,7 @@
 	   it is not there. */
 	/* will force a resize if the resize func returns 1 */
 	/* returns 1 on success, 0 if there's a problem, or it's already there. */
-	int bucket;
+	int bucket = 0;
 	if (tab->do_locking)
 		ast_rwlock_wrlock(&tab->lock);
 




More information about the svn-commits mailing list