summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerge script <automerge@asterisk.org>2013-01-03 20:19:37 +0000
committerAutomerge script <automerge@asterisk.org>2013-01-03 20:19:37 +0000
commitd359e1225e92ba9ff5ea557914838d2fe9eda3a2 (patch)
tree054ece8b6864eb8460c142f95785f2738a6ee936
parentf824b845ce70b8f74bf18b2e04a092230da7f64b (diff)
Merged revisions 378488 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk ................ r378488 | rmudgett | 2013-01-03 13:42:54 -0600 (Thu, 03 Jan 2013) | 15 lines chan_agent: Fix wrapup time wait response. * Made agent_cont_sleep() and agent_ack_sleep() stop waiting if the wrapup time expires. agent_cont_sleep() had tried but returned the wrong value to stop waiting. * Made agent_ack_sleep() take a struct agent_pvt pointer instead of a void pointer for better type safety. ........ Merged revisions 378486 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 378487 from http://svn.asterisk.org/svn/asterisk/branches/11 ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378495 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--channels/chan_agent.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index dc93c4ffd..1ed296845 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1022,42 +1022,38 @@ static int agent_hangup(struct ast_channel *ast)
return 0;
}
-static int agent_cont_sleep( void *data )
+static int agent_cont_sleep(void *data)
{
struct agent_pvt *p;
int res;
- p = (struct agent_pvt *)data;
+ p = (struct agent_pvt *) data;
ast_mutex_lock(&p->lock);
res = p->app_sleep_cond;
- if (p->lastdisc.tv_sec) {
- if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0)
- res = 1;
+ if (res && p->lastdisc.tv_sec) {
+ if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0) {
+ res = 0;
+ }
}
ast_mutex_unlock(&p->lock);
- if (!res)
- ast_debug(5, "agent_cont_sleep() returning %d\n", res );
+ if (!res) {
+ ast_debug(5, "agent_cont_sleep() returning %d\n", res);
+ }
return res;
}
-static int agent_ack_sleep(void *data)
+static int agent_ack_sleep(struct agent_pvt *p)
{
- struct agent_pvt *p;
- int res=0;
+ int digit;
int to = 1000;
struct ast_frame *f;
struct timeval start = ast_tvnow();
int ms;
/* Wait a second and look for something */
-
- p = (struct agent_pvt *) data;
- if (!p->chan)
- return -1;
-
while ((ms = ast_remaining_ms(start, to))) {
ms = ast_waitfor(p->chan, ms);
if (ms < 0) {
@@ -1067,23 +1063,31 @@ static int agent_ack_sleep(void *data)
return 0;
}
f = ast_read(p->chan);
- if (!f)
+ if (!f) {
return -1;
- if (f->frametype == AST_FRAME_DTMF)
- res = f->subclass.integer;
- else
- res = 0;
+ }
+ if (f->frametype == AST_FRAME_DTMF) {
+ digit = f->subclass.integer;
+ } else {
+ digit = 0;
+ }
ast_frfree(f);
ast_mutex_lock(&p->lock);
if (!p->app_sleep_cond) {
ast_mutex_unlock(&p->lock);
return 0;
- } else if (res == p->acceptdtmf) {
+ }
+ if (digit == p->acceptdtmf) {
ast_mutex_unlock(&p->lock);
return 1;
}
+ if (p->lastdisc.tv_sec) {
+ if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0) {
+ ast_mutex_unlock(&p->lock);
+ return 0;
+ }
+ }
ast_mutex_unlock(&p->lock);
- res = 0;
}
return 0;
}