diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-06 01:33:01 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-06 01:33:01 +0000 |
commit | 28ac723a337536809c6d8f363ff84037a548f690 (patch) | |
tree | b32c9541ad363f4d005d8e98b92952fc366c9b08 /channels | |
parent | a95870bdebdce6b672ff5bce92d9d3914c7858b0 (diff) |
Merged revisions 222176 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r222176 | kpfleming | 2009-10-05 20:24:24 -0500 (Mon, 05 Oct 2009) | 27 lines
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/branches/1.6.0@222185 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_console.c | 8 | ||||
-rw-r--r-- | channels/chan_iax2.c | 13 |
2 files changed, 20 insertions, 1 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c index b3a48a5c5..ab91131c7 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -1017,6 +1017,7 @@ static char *cli_list_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_a console_pvt_unlock(pvt); unref_pvt(pvt); } + ao2_iterator_destroy(&i); ast_cli(a->fd, "=============================================================\n\n"); @@ -1168,9 +1169,12 @@ static char *cli_console_active(struct ast_cli_entry *e, int cmd, struct ast_cli if (++x > a->n && !strncasecmp(pvt->name, a->word, strlen(a->word))) res = ast_strdup(pvt->name); unref_pvt(pvt); - if (res) + if (res) { + ao2_iterator_destroy(&i); return res; + } } + ao2_iterator_destroy(&i); } return NULL; } @@ -1370,6 +1374,7 @@ static void destroy_pvts(void) } unref_pvt(pvt); } + ao2_iterator_destroy(&i); } /*! @@ -1440,6 +1445,7 @@ static void stop_streams(void) stop_stream(pvt); unref_pvt(pvt); } + ao2_iterator_destroy(&i); } static int unload_module(void) diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index aad43194b..660303df3 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1451,6 +1451,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len) } peer_unref(peer); } + ao2_iterator_destroy(&i); if (!peer) { peer = realtime_peer(NULL, &sin); @@ -2191,6 +2192,7 @@ static char *handle_cli_iax2_show_callno_limits(struct ast_cli_entry *e, int cmd } ao2_ref(peercnt, -1); } + ao2_iterator_destroy(&i); if (a->argc == 4) { ast_cli(a->fd, "\nNon-CallToken Validation Limit: %d\nNon-CallToken Validated: %d\n", global_maxcallno_nonval, total_nonval_callno_used); @@ -3440,6 +3442,7 @@ static char *complete_iax2_show_peer(const char *line, const char *word, int pos } peer_unref(peer); } + ao2_iterator_destroy(&i); return res; } @@ -5142,6 +5145,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin) } peer_unref(peer); } + ao2_iterator_destroy(&i); return res; } @@ -6036,6 +6040,7 @@ static char *handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct user->contexts ? user->contexts->context : context, user->ha ? "Yes" : "No", pstr); } + ao2_iterator_destroy(&i); if (havepattern) regfree(®exbuf); @@ -6161,6 +6166,7 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, int argc peer->encmethods ? "(E)" : " ", status, term); total_peers++; } + ao2_iterator_destroy(&i); if (!s) ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term); @@ -6304,6 +6310,7 @@ static char *complete_iax2_unregister(const char *line, const char *word, int po } peer_unref(p); } + ao2_iterator_destroy(&i); } return res; @@ -6421,6 +6428,7 @@ static int manager_iax2_show_peer_list(struct mansession *s, const struct messag astman_append(s, "Status: %s\r\n\r\n", status); peer_count++; } + ao2_iterator_destroy(&i); astman_append(s, "Event: PeerlistComplete\r\n%sListItems: %d\r\n\r\n", idtext, peer_count); return RESULT_SUCCESS; @@ -7033,6 +7041,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies } user_unref(user); } + ao2_iterator_destroy(&i); user = best; if (!user && !ast_strlen_zero(iaxs[callno]->username)) { user = realtime_user(iaxs[callno]->username, sin); @@ -7562,6 +7571,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin, } peer_unref(peer); } + ao2_iterator_destroy(&i); if (!peer) { /* We checked our list and didn't find one. It's unlikely, but possible, that we're trying to authenticate *to* a realtime peer */ @@ -12139,6 +12149,7 @@ static void prune_users(void) } user_unref(user); } + ao2_iterator_destroy(&i); } /* Prune peers who still are supposed to be deleted */ @@ -12154,6 +12165,7 @@ static void prune_peers(void) } peer_unref(peer); } + ao2_iterator_destroy(&i); } static void set_timing(void) @@ -12607,6 +12619,7 @@ static void poke_all_peers(void) iax2_poke_peer(peer, 0); peer_unref(peer); } + ao2_iterator_destroy(&i); } static int reload_config(void) { |