aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-19 16:22:56 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-19 16:22:56 +0000
commit65117da50c17bed50607eb8709761c8f4c1c7b76 (patch)
treeaa1bc5feaf24bcaf72fdf2e8811cb04b51bca405 /res/res_odbc.c
parent9ebc2b5647e2842dc49b4d87673d5b50fcb2bac3 (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@117133 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index b685d047c..9103dbc3e 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -543,7 +543,6 @@ struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
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 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
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 @@ static int reload(void)
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;
}