aboutsummaryrefslogtreecommitdiffstats
path: root/main/channel.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-27 19:21:33 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-27 19:21:33 +0000
commitb710492a630fddfca8179a7ca99499a549d72508 (patch)
tree23da8666e0d6d6e5b6db991b229139971004bf72 /main/channel.c
parentdf5064fc4522ceb0020255f2a722a98511f1d393 (diff)
Merged revisions 184762 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines Improve timing interface to remember which provider provided a timer The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error. This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider. (closes issue #14697) Reported by: moy Review: http://reviewboard.digium.com/r/211/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@184779 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/main/channel.c b/main/channel.c
index 42ea4bfb3..c51747c96 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -807,17 +807,19 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
#endif
}
- tmp->timingfd = ast_timer_open();
- if (tmp->timingfd > -1) {
+ if ((tmp->timer = ast_timer_open())) {
needqueue = 0;
+ tmp->timingfd = ast_timer_fd(tmp->timer);
+ } else {
+ tmp->timingfd = -1;
}
if (needqueue) {
if (pipe(tmp->alertpipe)) {
ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n");
alertpipe_failed:
- if (tmp->timingfd > -1) {
- ast_timer_close(tmp->timingfd);
+ if (tmp->timer) {
+ ast_timer_close(tmp->timer);
}
sched_context_destroy(tmp->sched);
@@ -1010,7 +1012,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
chan->name, f->frametype, f->subclass, qlen, strerror(errno));
}
} else if (chan->timingfd > -1) {
- ast_timer_enable_continuous(chan->timingfd);
+ ast_timer_enable_continuous(chan->timer);
} else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
pthread_kill(chan->blocker, SIGURG);
}
@@ -1378,8 +1380,9 @@ void ast_channel_free(struct ast_channel *chan)
close(fd);
if ((fd = chan->alertpipe[1]) > -1)
close(fd);
- if ((fd = chan->timingfd) > -1)
- ast_timer_close(fd);
+ if (chan->timer) {
+ ast_timer_close(chan->timer);
+ }
#ifdef HAVE_EPOLL
for (i = 0; i < AST_MAX_FDS; i++) {
if (chan->epfd_data[i])
@@ -2325,13 +2328,13 @@ int ast_settimeout(struct ast_channel *c, unsigned int rate, int (*func)(const v
data = NULL;
}
- if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timingfd))) {
+ if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) {
real_rate = max_rate;
}
ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
- res = ast_timer_set_rate(c->timingfd, real_rate);
+ res = ast_timer_set_rate(c->timer, real_rate);
c->timingfunc = func;
c->timingdata = data;
@@ -2584,11 +2587,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
- res = ast_timer_get_event(chan->timingfd);
+ res = ast_timer_get_event(chan->timer);
switch (res) {
case AST_TIMING_EVENT_EXPIRED:
- ast_timer_ack(chan->timingfd, 1);
+ ast_timer_ack(chan->timer, 1);
if (chan->timingfunc) {
/* save a copy of func/data before unlocking the channel */
@@ -2598,7 +2601,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
ast_channel_unlock(chan);
func(data);
} else {
- ast_timer_set_rate(chan->timingfd, 0);
+ ast_timer_set_rate(chan->timer, 0);
chan->fdno = -1;
ast_channel_unlock(chan);
}
@@ -2609,7 +2612,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_TIMING_EVENT_CONTINUOUS:
if (AST_LIST_EMPTY(&chan->readq) ||
!AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) {
- ast_timer_disable_continuous(chan->timingfd);
+ ast_timer_disable_continuous(chan->timer);
}
break;
}