diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_console.c | 8 | ||||
-rw-r--r-- | channels/chan_iax2.c | 13 | ||||
-rw-r--r-- | channels/chan_sip.c | 49 |
3 files changed, 49 insertions, 21 deletions
diff --git a/channels/chan_console.c b/channels/chan_console.c index 4be7f92aa..ead0b1231 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -1013,6 +1013,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"); @@ -1162,9 +1163,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; } @@ -1367,6 +1371,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 c3bc2b38d..0feec77d1 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1640,6 +1640,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); @@ -2385,6 +2386,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); @@ -3641,6 +3643,7 @@ static char *complete_iax2_peers(const char *line, const char *word, int pos, in } peer_unref(peer); } + ao2_iterator_destroy(&i); return res; } @@ -5422,6 +5425,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin) } peer_unref(peer); } + ao2_iterator_destroy(&i); return res; } @@ -6326,6 +6330,7 @@ static char *handle_cli_iax2_show_users(struct ast_cli_entry *e, int cmd, struct user->contexts ? user->contexts->context : DEFAULT_CONTEXT, user->ha ? "Yes" : "No", pstr); } + ao2_iterator_destroy(&i); if (havepattern) regfree(®exbuf); @@ -6452,6 +6457,7 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, const in } 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); @@ -6595,6 +6601,7 @@ static char *complete_iax2_unregister(const char *line, const char *word, int po } peer_unref(p); } + ao2_iterator_destroy(&i); } return res; @@ -6715,6 +6722,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; @@ -7322,6 +7330,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); @@ -7856,6 +7865,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 */ @@ -12459,6 +12469,7 @@ static void prune_users(void) } user_unref(user); } + ao2_iterator_destroy(&i); } /* Prune peers who still are supposed to be deleted */ @@ -12474,6 +12485,7 @@ static void prune_peers(void) } peer_unref(peer); } + ao2_iterator_destroy(&i); } static void set_config_destroy(void) @@ -12950,6 +12962,7 @@ static void poke_all_peers(void) iax2_poke_peer(peer, 0); peer_unref(peer); } + ao2_iterator_destroy(&i); } static int reload_config(void) { diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4bfe696da..ee2c99eb3 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -14609,7 +14609,6 @@ static char *sip_show_inuse(struct ast_cli_entry *e, int cmd, struct ast_cli_arg ast_cli(a->fd, FORMAT, "* Peer name", "In use", "Limit"); i = ao2_iterator_init(peers, 0); - while ((peer = ao2_t_iterator_next(&i, "iterate thru peer table"))) { ao2_lock(peer); if (peer->call_limit) @@ -14622,6 +14621,7 @@ static char *sip_show_inuse(struct ast_cli_entry *e, int cmd, struct ast_cli_arg ao2_unlock(peer); unref_peer(peer, "toss iterator pointer"); } + ao2_iterator_destroy(&i); return CLI_SUCCESS; #undef FORMAT @@ -14813,6 +14813,7 @@ static char *sip_show_users(struct ast_cli_entry *e, int cmd, struct ast_cli_arg ao2_unlock(user); unref_peer(user, "sip show users"); } + ao2_iterator_destroy(&user_iter); if (havepattern) regfree(®exbuf); @@ -14987,6 +14988,7 @@ static char *_sip_show_peers(int fd, int *total, struct mansession *s, const str peerarray[total_peers++] = peer; ao2_unlock(peer); } + ao2_iterator_destroy(&i); qsort(peerarray, total_peers, sizeof(struct sip_peer *), peercomparefunc); @@ -15380,6 +15382,7 @@ static char *sip_prune_realtime(struct ast_cli_entry *e, int cmd, struct ast_cli ao2_unlock(pi); unref_peer(pi, "toss iterator peer ptr"); } + ao2_iterator_destroy(&i); if (pruned) { ao2_t_callback(peers, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, peer_is_marked, NULL, "initiating callback to remove marked peers"); @@ -15873,6 +15876,7 @@ static char *complete_sip_user(const char *word, int state) ao2_unlock(user); unref_peer(user, "complete sip user"); } + ao2_iterator_destroy(&user_iter); return result; } /*! \brief Support routine for 'sip show user' CLI */ @@ -16547,7 +16551,6 @@ static char *complete_sipch(const char *line, const char *word, int pos, int sta } i = ao2_iterator_init(dialogs, 0); - while ((cur = ao2_t_iterator_next(&i, "iterate thru dialogs"))) { sip_pvt_lock(cur); if (!strncasecmp(word, cur->callid, wordlen) && ++which > state) { @@ -16559,6 +16562,7 @@ static char *complete_sipch(const char *line, const char *word, int pos, int sta sip_pvt_unlock(cur); dialog_unref(cur, "drop ref in iterator loop"); } + ao2_iterator_destroy(&i); return c; } @@ -16583,6 +16587,7 @@ static char *complete_sip_peer(const char *word, int state, int flags2) break; } } + ao2_iterator_destroy(&i); return result; } @@ -16592,21 +16597,22 @@ static char *complete_sip_registered_peer(const char *word, int state, int flags char *result = NULL; int wordlen = strlen(word); int which = 0; - struct ao2_iterator i; - struct sip_peer *peer; - - i = ao2_iterator_init(peers, 0); - while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) { - if (!strncasecmp(word, peer->name, wordlen) && - (!flags2 || ast_test_flag(&peer->flags[1], flags2)) && - ++which > state && peer->expire > 0) - result = ast_strdup(peer->name); - if (result) { - unref_peer(peer, "toss iterator peer ptr before break"); - break; - } - unref_peer(peer, "toss iterator peer ptr"); + struct ao2_iterator i; + struct sip_peer *peer; + + i = ao2_iterator_init(peers, 0); + while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) { + if (!strncasecmp(word, peer->name, wordlen) && + (!flags2 || ast_test_flag(&peer->flags[1], flags2)) && + ++which > state && peer->expire > 0) + result = ast_strdup(peer->name); + if (result) { + unref_peer(peer, "toss iterator peer ptr before break"); + break; + } + unref_peer(peer, "toss iterator peer ptr"); } + ao2_iterator_destroy(&i); return result; } @@ -16692,7 +16698,6 @@ static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a len = strlen(a->argv[3]); i = ao2_iterator_init(dialogs, 0); - while ((cur = ao2_t_iterator_next(&i, "iterate thru dialogs"))) { sip_pvt_lock(cur); @@ -16772,6 +16777,7 @@ static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a ao2_t_ref(cur, -1, "toss dialog ptr set by iterator_next"); } + ao2_iterator_destroy(&i); if (!found) ast_cli(a->fd, "No such SIP Call ID starting with '%s'\n", a->argv[3]); @@ -16828,6 +16834,7 @@ static char *sip_show_history(struct ast_cli_entry *e, int cmd, struct ast_cli_a sip_pvt_unlock(cur); ao2_t_ref(cur, -1, "toss dialog ptr from iterator_next"); } + ao2_iterator_destroy(&i); if (!found) ast_cli(a->fd, "No such SIP Call ID starting with '%s'\n", a->argv[3]); @@ -22048,7 +22055,6 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, ignored (or generate errors) */ i = ao2_iterator_init(dialogs, 0); - while ((p_old = ao2_t_iterator_next(&i, "iterate thru dialogs"))) { if (p_old == p) { ao2_t_ref(p_old, -1, "toss dialog ptr from iterator_next before continue"); @@ -22075,6 +22081,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, sip_pvt_unlock(p_old); ao2_t_ref(p_old, -1, "toss dialog ptr from iterator_next"); } + ao2_iterator_destroy(&i); } if (!p->expiry) { pvt_set_needdestroy(p, "forcing expiration"); @@ -26109,11 +26116,10 @@ static void sip_poke_all_peers(void) struct ao2_iterator i; struct sip_peer *peer; - i = ao2_iterator_init(peers, 0); - if (!speerobjs) /* No peers, just give up */ return; + i = ao2_iterator_init(peers, 0); while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) { ao2_lock(peer); if (num == global_qualify_peers) { @@ -26129,6 +26135,7 @@ static void sip_poke_all_peers(void) ao2_unlock(peer); unref_peer(peer, "toss iterator peer ptr"); } + ao2_iterator_destroy(&i); } /*! \brief Send all known registrations */ @@ -26420,6 +26427,7 @@ static int unload_module(void) ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); ao2_t_ref(p, -1, "toss dialog ptr from iterator_next"); } + ao2_iterator_destroy(&i); ast_mutex_lock(&monlock); if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) { @@ -26436,6 +26444,7 @@ static int unload_module(void) dialog_unlink_all(p, TRUE, TRUE); ao2_t_ref(p, -1, "throw away iterator result"); } + ao2_iterator_destroy(&i); /* Free memory for local network address mask */ ast_free_ha(localaddr); |