[svn-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r302168 - in /team/dvossel/f...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jan 18 10:49:43 CST 2011


Author: dvossel
Date: Tue Jan 18 10:49:39 2011
New Revision: 302168

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=302168
Log:
Addition of ao2_link_nolock and ao2_unlink_nolock functions

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/astobj2.h
    team/dvossel/fixtheworld_phase1_step3/main/astobj2.c
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/astobj2.h?view=diff&rev=302168&r1=302167&r2=302168
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/astobj2.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/astobj2.h Tue Jan 18 10:49:39 2011
@@ -771,18 +771,20 @@
  */
 #ifdef REF_DEBUG
 
-#define ao2_t_link(arg1, arg2, arg3) __ao2_link_debug((arg1), (arg2), (arg3),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define ao2_link(arg1, arg2)         __ao2_link_debug((arg1), (arg2), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_link(arg1, arg2, arg3) __ao2_link_debug((arg1), (arg2), 0, (arg3),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_link(arg1, arg2)         __ao2_link_debug((arg1), (arg2), 0, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_link_nolock(arg1, arg2)  __ao2_link_debug((arg1), (arg2), OBJ_NOLOCK, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #else
 
-#define ao2_t_link(arg1, arg2, arg3) __ao2_link((arg1), (arg2))
-#define ao2_link(arg1, arg2)         __ao2_link((arg1), (arg2))
+#define ao2_t_link(arg1, arg2, arg3) __ao2_link((arg1), (arg2), 0)
+#define ao2_link(arg1, arg2)         __ao2_link((arg1), (arg2), 0)
+#define ao2_link_nolock(arg1, arg2)  __ao2_link((arg1), (arg2), OBJ_NOLOCK)
 
 #endif
 
-void *__ao2_link_debug(struct ao2_container *c, void *new_obj, char *tag, char *file, int line, const char *funcname);
-void *__ao2_link(struct ao2_container *c, void *newobj);
+void *__ao2_link_debug(struct ao2_container *c, void *new_obj, int flags, char *tag, char *file, int line, const char *funcname);
+void *__ao2_link(struct ao2_container *c, void *newobj, int flags);
 
 /*!
  * \brief Remove an object from a container
@@ -803,18 +805,20 @@
  */
 #ifdef REF_DEBUG
 
-#define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink_debug((arg1), (arg2), (arg3),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define ao2_unlink(arg1, arg2)         __ao2_unlink_debug((arg1), (arg2), "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink_debug((arg1), (arg2), 0, (arg3),  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_unlink(arg1, arg2)         __ao2_unlink_debug((arg1), (arg2), 0, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_unlink_nolock(arg1, arg2)  __ao2_unlink_debug((arg1), (arg2), OBJ_NOLOCK, "",  __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
 #else
 
-#define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink((arg1), (arg2))
-#define ao2_unlink(arg1, arg2)         __ao2_unlink((arg1), (arg2))
+#define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink((arg1), (arg2), 0)
+#define ao2_unlink(arg1, arg2)         __ao2_unlink((arg1), (arg2), 0)
+#define ao2_unlink_nolock(arg1, arg2)  __ao2_unlink((arg1), (arg2), OBJ_NOLOCK)
 
 #endif
 
-void *__ao2_unlink_debug(struct ao2_container *c, void *obj, char *tag, char *file, int line, const char *funcname);
-void *__ao2_unlink(struct ao2_container *c, void *obj);
+void *__ao2_unlink_debug(struct ao2_container *c, void *obj, int flags, char *tag, char *file, int line, const char *funcname);
+void *__ao2_unlink(struct ao2_container *c, void *obj, int flags);
 
 
 /*@} */

Modified: team/dvossel/fixtheworld_phase1_step3/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/astobj2.c?view=diff&rev=302168&r1=302167&r2=302168
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/astobj2.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/astobj2.c Tue Jan 18 10:49:39 2011
@@ -137,7 +137,7 @@
 static int internal_ao2_ref(void *user_data, const int delta);
 static struct ao2_container *internal_ao2_container_alloc(struct ao2_container *c, const uint n_buckets, ao2_hash_fn *hash_fn,
 							  ao2_callback_fn *cmp_fn);
-static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func);
+static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, int flags, const char *file, int line, const char *func);
 static void *internal_ao2_callback(struct ao2_container *c,
 				   const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type,
 				   char *tag, char *file, int line, const char *funcname);
@@ -471,7 +471,7 @@
  * link an object to a container
  */
 
-static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, const char *file, int line, const char *func)
+static struct bucket_entry *internal_ao2_link(struct ao2_container *c, void *user_data, int flags, const char *file, int line, const char *func)
 {
 	int i;
 	/* create a new list entry */
@@ -490,7 +490,9 @@
 
 	i = abs(c->hash_fn(user_data, OBJ_POINTER));
 
-	ao2_lock(c);
+	if (!(flags & OBJ_NOLOCK)) {
+		ao2_lock(c);
+	}
 	i %= c->n_buckets;
 	p->astobj = obj;
 	p->version = ast_atomic_fetchadd_int(&c->version, 1);
@@ -501,24 +503,28 @@
 	return p;
 }
 
-void *__ao2_link_debug(struct ao2_container *c, void *user_data, char *tag, char *file, int line, const char *funcname)
-{
-	struct bucket_entry *p = internal_ao2_link(c, user_data, file, line, funcname);
+void *__ao2_link_debug(struct ao2_container *c, void *user_data, int flags, char *tag, char *file, int line, const char *funcname)
+{
+	struct bucket_entry *p = internal_ao2_link(c, user_data, flags, file, line, funcname);
 
 	if (p) {
 		__ao2_ref_debug(user_data, +1, tag, file, line, funcname);
-		ao2_unlock(c);
+		if (!(flags & OBJ_NOLOCK)) {
+			ao2_unlock(c);
+		}
 	}
 	return p;
 }
 
-void *__ao2_link(struct ao2_container *c, void *user_data)
-{
-	struct bucket_entry *p = internal_ao2_link(c, user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__);
+void *__ao2_link(struct ao2_container *c, void *user_data, int flags)
+{
+	struct bucket_entry *p = internal_ao2_link(c, user_data, flags, __FILE__, __LINE__, __PRETTY_FUNCTION__);
 
 	if (p) {
 		__ao2_ref(user_data, +1);
-		ao2_unlock(c);
+		if (!(flags & OBJ_NOLOCK)) {
+			ao2_unlock(c);
+		}
 	}
 	return p;
 }
@@ -535,23 +541,26 @@
  * Unlink an object from the container
  * and destroy the associated * bucket_entry structure.
  */
-void *__ao2_unlink_debug(struct ao2_container *c, void *user_data, char *tag,
+void *__ao2_unlink_debug(struct ao2_container *c, void *user_data, int flags, char *tag,
 			 char *file, int line, const char *funcname)
 {
 	if (INTERNAL_OBJ(user_data) == NULL)	/* safety check on the argument */
 		return NULL;
 
-	__ao2_callback_debug(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data, tag, file, line, funcname);
+	flags |= (OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA);
+
+	__ao2_callback_debug(c, flags, ao2_match_by_addr, user_data, tag, file, line, funcname);
 
 	return NULL;
 }
 
-void *__ao2_unlink(struct ao2_container *c, void *user_data)
+void *__ao2_unlink(struct ao2_container *c, void *user_data, int flags)
 {
 	if (INTERNAL_OBJ(user_data) == NULL)	/* safety check on the argument */
 		return NULL;
 
-	__ao2_callback(c, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA, ao2_match_by_addr, user_data);
+	flags |= (OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA);
+	__ao2_callback(c, flags, ao2_match_by_addr, user_data);
 
 	return NULL;
 }
@@ -696,7 +705,7 @@
 			 * link the object into the container that will hold the results.
 			 */
 			if (ret && (multi_container != NULL)) {
-				__ao2_link(multi_container, ret);
+				__ao2_link(multi_container, ret, flags);
 				ret = NULL;
 			}
 

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=302168&r1=302167&r2=302168
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Tue Jan 18 10:49:39 2011
@@ -99,7 +99,7 @@
 		return;
 	}
 	ast_format_copy(fnew, format);
-	ao2_link(cap->formats, fnew);
+	ao2_link_nolock(cap->formats, fnew);
 	ao2_ref(fnew, -1);
 }
 
@@ -252,7 +252,7 @@
 	it = ao2_iterator_init(cap->formats, AO2_ITERATOR_DONTLOCK);
 	while ((tmp = ao2_iterator_next(&it))) {
 		if (AST_FORMAT_GET_TYPE(tmp->id) == type) {
-			ao2_unlink(cap->formats, tmp);
+			ao2_callback(cap->formats, OBJ_UNLINK | OBJ_POINTER | OBJ_NODATA | OBJ_NOLOCK, cmp_cb, tmp);
 		}
 		ao2_ref(tmp, -1);
 	}




More information about the svn-commits mailing list