[asterisk-commits] rmudgett: branch rmudgett/ao2_enhancements r357263 - in /team/rmudgett/ao2_en...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 28 11:41:07 CST 2012


Author: rmudgett
Date: Tue Feb 28 11:41:03 2012
New Revision: 357263

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357263
Log:
Update container clone/dup to handle locking options.

Modified:
    team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h
    team/rmudgett/ao2_enhancements/main/astobj2.c

Modified: team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h?view=diff&rev=357263&r1=357262&r2=357263
==============================================================================
--- team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h (original)
+++ team/rmudgett/ao2_enhancements/include/asterisk/astobj2.h Tue Feb 28 11:41:03 2012
@@ -875,7 +875,7 @@
  * \retval NULL on error.
  */
 struct ao2_container *__ao2_container_clone(struct ao2_container *orig, enum search_flags flags);
-struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, enum search_flags flags, const char *tag, char *file, int line, const char *funcname, int ref_debug);
+struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, enum search_flags flags, const char *tag, const char *file, int line, const char *funcname, int ref_debug);
 #if defined(REF_DEBUG)
 
 #define ao2_t_container_clone(orig, flags, tag)	__ao2_container_clone_debug(orig, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)

Modified: team/rmudgett/ao2_enhancements/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_enhancements/main/astobj2.c?view=diff&rev=357263&r1=357262&r2=357263
==============================================================================
--- team/rmudgett/ao2_enhancements/main/astobj2.c (original)
+++ team/rmudgett/ao2_enhancements/main/astobj2.c Tue Feb 28 11:41:03 2012
@@ -1344,8 +1344,8 @@
 	int res = 0;
 
 	if (!(flags & OBJ_NOLOCK)) {
-		ao2_lock(src);
-		ao2_lock(dest);
+		ao2_rdlock(src);
+		ao2_wrlock(dest);
 	}
 	obj = __ao2_callback(src, OBJ_NOLOCK, dup_obj_cb, dest);
 	if (obj) {
@@ -1368,16 +1368,24 @@
 struct ao2_container *__ao2_container_clone(struct ao2_container *orig, enum search_flags flags)
 {
 	struct ao2_container *clone;
+	struct astobj2 *orig_obj;
+	unsigned int options;
 	int failed;
 
+	orig_obj = INTERNAL_OBJ(orig);
+	if (!orig_obj) {
+		return NULL;
+	}
+	options = orig_obj->priv_data.options;
+
 	/* Create the clone container with the same properties as the original. */
-	clone = __ao2_container_alloc(orig->n_buckets, orig->hash_fn, orig->cmp_fn);
+	clone = __ao2_container_alloc(options, orig->n_buckets, orig->hash_fn, orig->cmp_fn);
 	if (!clone) {
 		return NULL;
 	}
 
 	if (flags & OBJ_NOLOCK) {
-		ao2_lock(clone);
+		ao2_wrlock(clone);
 	}
 	failed = ao2_container_dup(clone, orig, flags);
 	if (flags & OBJ_NOLOCK) {
@@ -1391,20 +1399,28 @@
 	return clone;
 }
 
-struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, enum search_flags flags, const char *tag, char *file, int line, const char *funcname, int ref_debug)
+struct ao2_container *__ao2_container_clone_debug(struct ao2_container *orig, enum search_flags flags, const char *tag, const char *file, int line, const char *funcname, int ref_debug)
 {
 	struct ao2_container *clone;
+	struct astobj2 *orig_obj;
+	unsigned int options;
 	int failed;
 
+	orig_obj = INTERNAL_OBJ(orig);
+	if (!orig_obj) {
+		return NULL;
+	}
+	options = orig_obj->priv_data.options;
+
 	/* Create the clone container with the same properties as the original. */
-	clone = __ao2_container_alloc_debug(orig->n_buckets, orig->hash_fn, orig->cmp_fn, tag,
-		file, line, funcname, ref_debug);
+	clone = __ao2_container_alloc_debug(options, orig->n_buckets, orig->hash_fn,
+		orig->cmp_fn, tag, file, line, funcname, ref_debug);
 	if (!clone) {
 		return NULL;
 	}
 
 	if (flags & OBJ_NOLOCK) {
-		ao2_lock(clone);
+		ao2_wrlock(clone);
 	}
 	failed = ao2_container_dup(clone, orig, flags);
 	if (flags & OBJ_NOLOCK) {




More information about the asterisk-commits mailing list