[asterisk-commits] file: trunk r117133 - /trunk/res/res_odbc.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 19 11:22:56 CDT 2008


Author: file
Date: Mon May 19 11:22:56 2008
New Revision: 117133

URL: http://svn.digium.com/view/asterisk?view=rev&rev=117133
Log:
Remove a premature mutex destroy (the destruction callback will end up destroying it) and use a callback to purge remaining classes.
(closes issue #12677)
Reported by: falves11

Modified:
    trunk/res/res_odbc.c

Modified: trunk/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_odbc.c?view=diff&rev=117133&r1=117132&r2=117133
==============================================================================
--- trunk/res/res_odbc.c (original)
+++ trunk/res/res_odbc.c Mon May 19 11:22:56 2008
@@ -543,7 +543,6 @@
 			obj->parent = class;
 			if (odbc_obj_connect(obj) == ODBC_FAIL) {
 				ast_log(LOG_WARNING, "Failed to connect to %s\n", name);
-				ast_mutex_destroy(&obj->lock);
 				ao2_ref(obj, -1);
 				obj = NULL;
 			} else {
@@ -631,10 +630,27 @@
 	return ODBC_SUCCESS;
 }
 
+static int class_is_delme(void *classobj, void *arg, int flags)
+{
+	struct odbc_class *class = classobj;
+
+	if (class->delme) {
+		struct odbc_obj *obj;
+		struct ao2_iterator aoi = ao2_iterator_init(class->obj_container, OBJ_UNLINK);
+		while ((obj = ao2_iterator_next(&aoi))) {
+			ao2_ref(obj, -2);
+		}
+		return CMP_MATCH;
+	}
+
+	return 0;
+}
+
+
+
 static int reload(void)
 {
 	struct odbc_class *class;
-	struct odbc_obj *current;
 	struct ao2_iterator aoi = ao2_iterator_init(class_container, 0);
 
 	/* First, mark all to be purged */
@@ -646,17 +662,7 @@
 	load_odbc_config();
 
 	/* Purge remaining classes */
-	aoi = ao2_iterator_init(class_container, OBJ_UNLINK);
-	while ((class = ao2_iterator_next(&aoi))) {
-		if (class->delme) {
-			struct ao2_iterator aoi2 = ao2_iterator_init(class->obj_container, OBJ_UNLINK);
-			while ((current = ao2_iterator_next(&aoi2))) {
-				ao2_ref(current, -2);
-			}
-			ao2_ref(class, -1);
-		}
-		ao2_ref(class, -1);
-	}
+	ao2_callback(class_container, OBJ_NODATA | OBJ_UNLINK, class_is_delme, 0);
 
 	return 0;
 }




More information about the asterisk-commits mailing list