[asterisk-commits] russell: branch russell/ast_channel_ao2 r183441 - in /team/russell/ast_channe...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 19 16:11:24 CDT 2009
Author: russell
Date: Thu Mar 19 16:11:21 2009
New Revision: 183441
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183441
Log:
Fix up features.c and ...
_____ _ _
| ____|_ __ __ _| |__ | | ___
| _| | '_ \ / _` | '_ \| |/ _ \
| |___| | | | (_| | |_) | | __/
|_____|_| |_|\__,_|_.__/|_|\___|
___ _
/ _ \ _ _| |_ ___ _ __ ___ ___ _ __ __ _ ___
| |_| | | | | __/ _ \| '_ ` _ \ / _ \ '__/ _` |/ _ \
| _ | |_| | || (_) | | | | | | __/ | | (_| | __/
|_| |_|\__,_|\__\___/|_| |_| |_|\___|_| \__, |\___|
|___/
Modified:
team/russell/ast_channel_ao2/ (props changed)
team/russell/ast_channel_ao2/apps/app_dahdiscan.c
team/russell/ast_channel_ao2/include/asterisk/channel.h
team/russell/ast_channel_ao2/main/features.c
Propchange: team/russell/ast_channel_ao2/
------------------------------------------------------------------------------
automerge = *
Modified: team/russell/ast_channel_ao2/apps/app_dahdiscan.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/apps/app_dahdiscan.c?view=diff&rev=183441&r1=183440&r2=183441
==============================================================================
--- team/russell/ast_channel_ao2/apps/app_dahdiscan.c (original)
+++ team/russell/ast_channel_ao2/apps/app_dahdiscan.c Thu Mar 19 16:11:21 2009
@@ -32,6 +32,7 @@
/*** MODULEINFO
<depend>dahdi</depend>
+ <defaultenabled>no</defaultenabled>
***/
#include "asterisk.h"
Modified: team/russell/ast_channel_ao2/include/asterisk/channel.h
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/include/asterisk/channel.h?view=diff&rev=183441&r1=183440&r2=183441
==============================================================================
--- team/russell/ast_channel_ao2/include/asterisk/channel.h (original)
+++ team/russell/ast_channel_ao2/include/asterisk/channel.h Thu Mar 19 16:11:21 2009
@@ -1902,7 +1902,7 @@
* This function executes a callback one time for each active channel on the
* system. The channel is provided as an argument to the function.
*/
-struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
+struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
void *data, int ao2_flags);
/*! @{ Channel search functions */
Modified: team/russell/ast_channel_ao2/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/main/features.c?view=diff&rev=183441&r1=183440&r2=183441
==============================================================================
--- team/russell/ast_channel_ao2/main/features.c (original)
+++ team/russell/ast_channel_ao2/main/features.c Thu Mar 19 16:11:21 2009
@@ -4146,12 +4146,8 @@
return 0;
}
- /* The same code must be executed for chana and chanb. To avoid a
- * theoretical deadlock, this code is separated so both chana and chanb will
- * not hold locks at the same time. */
-
/* Start with chana */
- chana = ast_get_channel_by_name_prefix_locked(channela, strlen(channela));
+ chana = ast_channel_get_by_name_prefix(channela, strlen(channela));
/* send errors if any of the channels could not be found/locked */
if (!chana) {
@@ -4169,16 +4165,16 @@
if (!(tmpchana = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
NULL, NULL, 0, "Bridge/%s", chana->name))) {
astman_send_error(s, m, "Unable to create temporary channel!");
- ast_channel_unlock(chana);
+ chana = ast_channel_unref(chana);
return 1;
}
do_bridge_masquerade(chana, tmpchana);
- ast_channel_unlock(chana);
- chana = NULL;
+
+ chana = ast_channel_unref(chana);
/* now do chanb */
- chanb = ast_get_channel_by_name_prefix_locked(channelb, strlen(channelb));
+ chanb = ast_channel_get_by_name_prefix(channelb, strlen(channelb));
/* send errors if any of the channels could not be found/locked */
if (!chanb) {
char buf[256];
@@ -4197,12 +4193,13 @@
NULL, NULL, 0, "Bridge/%s", chanb->name))) {
astman_send_error(s, m, "Unable to create temporary channels!");
ast_hangup(tmpchana);
- ast_channel_unlock(chanb);
+ chanb = ast_channel_unref(chanb);
return 1;
}
+
do_bridge_masquerade(chanb, tmpchanb);
- ast_channel_unlock(chanb);
- chanb = NULL;
+
+ chanb = ast_channel_unref(chanb);
/* make the channels compatible, send error if we fail doing so */
if (ast_channel_make_compatible(tmpchana, tmpchanb)) {
@@ -4210,8 +4207,6 @@
astman_send_error(s, m, "Could not make channels compatible for manager bridge");
ast_hangup(tmpchana);
ast_hangup(tmpchanb);
- chana = ast_channel_unref(chana);
- chanb = ast_channel_unref(chanb);
return 1;
}
@@ -4221,8 +4216,6 @@
astman_send_error(s, m, "Unable to spawn a new bridge thread");
ast_hangup(tmpchana);
ast_hangup(tmpchanb);
- chana = ast_channel_unref(chana);
- chanb = ast_channel_unref(chanb);
return 1;
}
@@ -4240,9 +4233,6 @@
bridge_call_thread_launch(tobj);
astman_send_ack(s, m, "Launched bridge thread with success");
-
- chana = ast_channel_unref(chana);
- chanb = ast_channel_unref(chanb);
return 0;
}
@@ -4469,52 +4459,47 @@
*/
int ast_pickup_call(struct ast_channel *chan)
{
- struct ast_channel *cur = ast_channel_search_locked(find_channel_by_group, chan);
-
- if (cur) {
- int res = -1;
- ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
- res = ast_answer(chan);
- if (res)
- ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
- res = ast_queue_control(chan, AST_CONTROL_ANSWER);
- if (res)
- ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan->name);
- res = ast_channel_masquerade(cur, chan);
- if (res)
- ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */
- if (!ast_strlen_zero(pickupsound)) {
- ast_stream_and_wait(cur, pickupsound, "");
- }
- ast_channel_unlock(cur);
- return res;
- } else {
+ struct ast_channel *cur;
+ int res = -1;
+ const char *chan_name;
+ const char *cur_name;
+
+ if (!(cur = ast_channel_callback(find_channel_by_group, NULL, chan, 0))) {
ast_debug(1, "No call pickup possible...\n");
if (!ast_strlen_zero(pickupfailsound)) {
ast_stream_and_wait(chan, pickupfailsound, "");
}
}
- ast_channel_lock(pickup_chan);
-
- ast_debug(1, "Call pickup on chan '%s' by '%s'\n",
- pickup_chan->name, chan->name);
+ ast_channel_lock(chan);
+ chan_name = ast_strdupa(chan->name);
+ ast_channel_unlock(chan);
+
+ ast_channel_lock(cur);
+ cur_name = ast_strdupa(cur->name);
+ ast_channel_unlock(cur);
+
+ ast_debug(1, "Call pickup on chan '%s' by '%s'\n", cur_name, chan_name);
if ((res = ast_answer(chan))) {
- ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
+ ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan_name);
}
if ((res = ast_queue_control(chan, AST_CONTROL_ANSWER))) {
- ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan->name);
- }
-
- if ((res = ast_channel_masquerade(pickup_chan, chan))) {
- ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n",
- chan->name, pickup_chan->name);
- }
-
- ast_channel_unlock(pickup_chan);
- pickup_chan = ast_channel_unref(pickup_chan);
+ ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan_name);
+ }
+
+ if ((res = ast_channel_masquerade(cur, chan))) {
+ ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan_name, cur_name);
+ }
+
+ if (!ast_strlen_zero(pickupsound)) {
+ ast_channel_lock(cur);
+ ast_stream_and_wait(cur, pickupsound, "");
+ ast_channel_unlock(cur);
+ }
+
+ cur = ast_channel_unref(cur);
return res;
}
More information about the asterisk-commits
mailing list