aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_odbc.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-06 01:24:24 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-06 01:24:24 +0000
commite299cf0653557f0e54cf263b07c0201eebef00d8 (patch)
tree25c2e24721eb7de30f085f43103b8aff55e28fa5 /res/res_odbc.c
parentf5671885b8cce3822782ff45a84c983628e84a66 (diff)
Recorded merge of revisions 222152 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r222152 | kpfleming | 2009-10-05 20:16:36 -0500 (Mon, 05 Oct 2009) | 20 lines Fix ao2_iterator API to hold references to containers being iterated. See Mantis issue for details of what prompted this change. Additional notes: This patch changes the ao2_iterator API in two ways: F_AO2I_DONTLOCK has become an enum instead of a macro, with a name that fits our naming policy; also, it is now necessary to call ao2_iterator_destroy() on any iterator that has been created. Currently this only releases the reference to the container being iterated, but in the future this could also release other resources used by the iterator, if the iterator implementation changes to use additional resources. (closes issue #15987) Reported by: kpfleming Review: https://reviewboard.asterisk.org/r/383/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@222176 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_odbc.c')
-rw-r--r--res/res_odbc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 2fec8884e..9498cc591 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -898,6 +898,7 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
break;
}
}
+ ao2_iterator_destroy(&aoi);
if (!ret && !strncasecmp(a->word, "all", length) && ++which > a->n) {
ret = ast_strdup("all");
}
@@ -932,6 +933,7 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
ast_mutex_unlock(&current->lock);
ao2_ref(current, -1);
}
+ ao2_iterator_destroy(&aoi2);
} else {
/* Should only ever be one of these (unless there are transactions) */
struct ao2_iterator aoi2 = ao2_iterator_init(class->obj_container, 0);
@@ -940,11 +942,13 @@ static char *handle_cli_odbc_show(struct ast_cli_entry *e, int cmd, struct ast_c
current->up && ast_odbc_sanity_check(current) ? "Yes" : "No");
ao2_ref(current, -1);
}
+ ao2_iterator_destroy(&aoi2);
}
ast_cli(a->fd, "\n");
}
ao2_ref(class, -1);
}
+ ao2_iterator_destroy(&aoi);
return CLI_SUCCESS;
}
@@ -1609,6 +1613,7 @@ static int reload(void)
class->delme = 1;
ao2_ref(class, -1);
}
+ ao2_iterator_destroy(&aoi);
load_odbc_config();
@@ -1648,6 +1653,7 @@ static int reload(void)
* b) the object has already been destroyed.
*/
}
+ ao2_iterator_destroy(&aoi2);
ao2_unlink(class_container, class); /* unlink C-ref from container (reference handled implicitly) */
/* At this point, either
* a) there's an outstanding O-ref, which holds an outstanding C-ref, or
@@ -1657,6 +1663,7 @@ static int reload(void)
}
ao2_ref(class, -1); /* C-ref-- (by iterator) */
}
+ ao2_iterator_destroy(&aoi);
/* Empty the cache; it will get rebuilt the next time the tables are needed. */
AST_RWLIST_WRLOCK(&odbc_tables);