summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2008-11-09 01:59:59 +0000
committerSean Bright <sean@malleable.com>2008-11-09 01:59:59 +0000
commit48522988ab2ff7b73a327eac20b248c02e6ef981 (patch)
tree5e7ff2cd6ece5b2ac5438a59b2737c5705b928cc /main
parent9ef09ad1d464defbef1775281e7666af888b6086 (diff)
In order to move away from nested function use, some changes to the recently introduced
ast_channel_search_locked need to be made. Specifically, the caller needs to be able to pass arbitrary data which in turn is passed to the callback. This patch addresses all of the nested functions currently in asterisk trunk. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@155590 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/channel.c4
-rw-r--r--main/features.c22
2 files changed, 15 insertions, 11 deletions
diff --git a/main/channel.c b/main/channel.c
index ec253ae04..b5a4054a4 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1227,14 +1227,14 @@ struct ast_channel *ast_walk_channel_by_exten_locked(const struct ast_channel *c
}
/*! \brief Search for a channel based on the passed channel matching callback (first match) and return it, locked */
-struct ast_channel *ast_channel_search_locked(int (*is_match)(struct ast_channel *))
+struct ast_channel *ast_channel_search_locked(int (*is_match)(struct ast_channel *, void *), void *data)
{
struct ast_channel *c = NULL;
AST_RWLIST_RDLOCK(&channels);
AST_RWLIST_TRAVERSE(&channels, c, chan_list) {
ast_channel_lock(c);
- if (is_match(c)) {
+ if (is_match(c, data)) {
break;
}
ast_channel_unlock(c);
diff --git a/main/features.c b/main/features.c
index ed13ee4fc..932f1b8a1 100644
--- a/main/features.c
+++ b/main/features.c
@@ -3987,6 +3987,18 @@ static int manager_park(struct mansession *s, const struct message *m)
return 0;
}
+static int find_channel_by_group(struct ast_channel *c, void *data) {
+ struct ast_channel *chan = data;
+
+ return !c->pbx &&
+ /* Accessing 'chan' here is safe without locking, because there is no way for
+ the channel do disappear from under us at this point. pickupgroup *could*
+ change while we're here, but that isn't a problem. */
+ (c != chan) &&
+ (chan->pickupgroup & c->callgroup) &&
+ ((c->_state == AST_STATE_RINGING) || (c->_state == AST_STATE_RING));
+}
+
/*!
* \brief Pickup a call
* \param chan channel that initiated pickup.
@@ -3997,15 +4009,7 @@ static int manager_park(struct mansession *s, const struct message *m)
*/
int ast_pickup_call(struct ast_channel *chan)
{
- auto int find_channel_by_group(struct ast_channel *);
- int find_channel_by_group(struct ast_channel *c) {
- return !c->pbx &&
- (c != chan) &&
- (chan->pickupgroup & c->callgroup) &&
- ((c->_state == AST_STATE_RINGING) ||
- (c->_state == AST_STATE_RING));
- }
- struct ast_channel *cur = ast_channel_search_locked(find_channel_by_group);
+ struct ast_channel *cur = ast_channel_search_locked(find_channel_by_group, chan);
if (cur) {
int res = -1;