diff options
Diffstat (limited to 'apps/app_softhangup.c')
-rw-r--r-- | apps/app_softhangup.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/app_softhangup.c b/apps/app_softhangup.c index a7ba753fd..6a4889acf 100644 --- a/apps/app_softhangup.c +++ b/apps/app_softhangup.c @@ -80,6 +80,7 @@ static int softhangup_exec(struct ast_channel *chan, void *data) AST_APP_ARG(channel); AST_APP_ARG(options); ); + struct ast_channel_iterator *iter; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n"); @@ -93,9 +94,12 @@ static int softhangup_exec(struct ast_channel *chan, void *data) ast_app_parse_options(app_opts, &flags, opts, args.options); lenmatch = strlen(args.channel); - for (c = ast_walk_channel_by_name_prefix_locked(NULL, args.channel, lenmatch); - c; - c = ast_walk_channel_by_name_prefix_locked(c, args.channel, lenmatch)) { + if (!(iter = ast_channel_iterator_by_name_new(0, args.channel, lenmatch))) { + return -1; + } + + while ((c = ast_channel_iterator_next(iter))) { + ast_channel_lock(c); ast_copy_string(name, c->name, sizeof(name)); if (ast_test_flag(&flags, OPTION_ALL)) { /* CAPI is set up like CAPI[foo/bar]/clcnt */ @@ -113,12 +117,16 @@ static int softhangup_exec(struct ast_channel *chan, void *data) ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT); if (!ast_test_flag(&flags, OPTION_ALL)) { ast_channel_unlock(c); + c = ast_channel_unref(c); break; } } ast_channel_unlock(c); + c = ast_channel_unref(c); } + ast_channel_iterator_destroy(iter); + return 0; } |