[asterisk-commits] rmudgett: branch 11 r378487 - in /branches/11: ./ channels/chan_agent.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 3 13:41:59 CST 2013


Author: rmudgett
Date: Thu Jan  3 13:41:56 2013
New Revision: 378487

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378487
Log:
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

Modified:
    branches/11/   (props changed)
    branches/11/channels/chan_agent.c

Propchange: branches/11/
------------------------------------------------------------------------------
--- branch-1.8-merged (original)
+++ branch-1.8-merged Thu Jan  3 13:41:56 2013
@@ -1,1 +1,1 @@
-/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456
+/branches/1.8:1-378147,378164,378356,378375,378427,378455-378456,378486

Modified: branches/11/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_agent.c?view=diff&rev=378487&r1=378486&r2=378487
==============================================================================
--- branches/11/channels/chan_agent.c (original)
+++ branches/11/channels/chan_agent.c Thu Jan  3 13:41:56 2013
@@ -1022,42 +1022,38 @@
 	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)
-{
-	struct agent_pvt *p;
-	int res=0;
+static int agent_ack_sleep(struct agent_pvt *p)
+{
+	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 @@
 			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;
 }




More information about the asterisk-commits mailing list