aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_directed_pickup.c
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-09 16:47:07 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2011-06-09 16:47:07 +0000
commit017a892d868e1243953fd8f0db10aeae80f3241d (patch)
tree6132cd6991a104993a524ca957535c1f880b5bc8 /apps/app_directed_pickup.c
parentad49525abc4706833fdfb4a75a18ff3c64241379 (diff)
Merged revisions 322749 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r322749 | rmudgett | 2011-06-09 11:31:53 -0500 (Thu, 09 Jun 2011) | 15 lines Remove potential deadlock in call pickup race. Deadlock is possible in ast_do_pickup() when holding the target channel lock and trying to get the chan channel lock. Also, holding the target lock when calling ast_channel_masquerade() is not a good idea because that routine does deadlock avoidance. * Removed the need to hold the target lock after marking the target with a datastore and getting the connected line data off of the target channel. * Moved can_pickup() to ast_can_pickup() in features.c. Now all the call pickup methods use the same basic call pickup availability check. Review: https://reviewboard.asterisk.org/r/1234/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@322750 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_directed_pickup.c')
-rw-r--r--apps/app_directed_pickup.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index 38f24effc..63a7621ff 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -97,19 +97,6 @@ static const char app[] = "Pickup";
static const char app2[] = "PickupChan";
/*! \todo This application should return a result code, like PICKUPRESULT */
-/* Helper function that determines whether a channel is capable of being picked up */
-static int can_pickup(struct ast_channel *chan)
-{
- if (!chan->pbx && !chan->masq &&
- !ast_test_flag(chan, AST_FLAG_ZOMBIE) &&
- (chan->_state == AST_STATE_RINGING ||
- chan->_state == AST_STATE_RING ||
- chan->_state == AST_STATE_DOWN)) {
- return 1;
- }
- return 0;
-}
-
struct pickup_by_name_args {
const char *name;
size_t len;
@@ -121,7 +108,7 @@ static int pickup_by_name_cb(void *obj, void *arg, void *data, int flags)
struct pickup_by_name_args *args = data;
ast_channel_lock(target);
- if (!strncasecmp(target->name, args->name, args->len) && can_pickup(target)) {
+ if (!strncasecmp(target->name, args->name, args->len) && ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
}
@@ -190,7 +177,7 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
while ((target = ast_channel_iterator_next(iter))) {
ast_channel_lock(target);
- if ((chan != target) && can_pickup(target)) {
+ if ((chan != target) && ast_can_pickup(target)) {
ast_log(LOG_NOTICE, "%s pickup by %s\n", target->name, chan->name);
break;
}
@@ -217,7 +204,7 @@ static int find_by_mark(void *obj, void *arg, void *data, int flags)
ast_channel_lock(target);
tmp = pbx_builtin_getvar_helper(target, PICKUPMARK);
- if (tmp && !strcasecmp(tmp, mark) && can_pickup(target)) {
+ if (tmp && !strcasecmp(tmp, mark) && ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
}
@@ -249,7 +236,8 @@ static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
struct ast_channel *chan = data;/*!< Channel wanting to pickup call */
ast_channel_lock(target);
- if (chan != target && (chan->pickupgroup & target->callgroup) && can_pickup(target)) {
+ if (chan != target && (chan->pickupgroup & target->callgroup)
+ && ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
}
@@ -316,7 +304,7 @@ static int find_by_part(void *obj, void *arg, void *data, int flags)
ast_channel_lock(target);
if (len <= strlen(target->name) && !strncmp(target->name, part, len)
- && can_pickup(target)) {
+ && ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
}