From 1c9fe00920c4d887328400bf43c3e16fc9d24c37 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Tue, 6 Oct 2009 01:24:24 +0000 Subject: 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: https://origsvn.digium.com/svn/asterisk/trunk@222176 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_musiconhold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'res/res_musiconhold.c') diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 090f927a2..b5bc77d74 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -1608,7 +1608,6 @@ static char *handle_cli_moh_show_files(struct ast_cli_entry *e, int cmd, struct return CLI_SHOWUSAGE; i = ao2_iterator_init(mohclasses, 0); - for (; (class = ao2_t_iterator_next(&i, "Show files iterator")); mohclass_unref(class, "Unref iterator in moh show files")) { int x; @@ -1621,6 +1620,7 @@ static char *handle_cli_moh_show_files(struct ast_cli_entry *e, int cmd, struct ast_cli(a->fd, "\tFile: %s\n", class->filearray[x]); } } + ao2_iterator_destroy(&i); return CLI_SUCCESS; } @@ -1645,7 +1645,6 @@ static char *handle_cli_moh_show_classes(struct ast_cli_entry *e, int cmd, struc return CLI_SHOWUSAGE; i = ao2_iterator_init(mohclasses, 0); - for (; (class = ao2_t_iterator_next(&i, "Show classes iterator")); mohclass_unref(class, "Unref iterator in moh show classes")) { ast_cli(a->fd, "Class: %s\n", class->name); ast_cli(a->fd, "\tMode: %s\n", S_OR(class->mode, "")); @@ -1657,6 +1656,7 @@ static char *handle_cli_moh_show_classes(struct ast_cli_entry *e, int cmd, struc ast_cli(a->fd, "\tFormat: %s\n", ast_getformatname(class->format)); } } + ao2_iterator_destroy(&i); return CLI_SUCCESS; } -- cgit v1.2.3