aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-05 18:31:06 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-03-05 18:31:06 +0000
commit1ef81d9de374e12788b0e44c09cc32b6e20ebe9d (patch)
treecdbed37453af81324f2b57ba55af561a3178bb30 /channel.c
parent4337816856d05e2fe3da99f6a393572c0a5ae4fc (diff)
Minor optimizations and actually set SOFTHANGUP_TIMEOUT if appropriate
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2351 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/channel.c b/channel.c
index 603796a42..1f50afefb 100755
--- a/channel.c
+++ b/channel.c
@@ -809,7 +809,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
fd_set rfds, efds;
int res;
int x, y, max=-1;
- time_t now;
+ time_t now = 0;
long whentohangup = 0, havewhen = 0, diff;
struct ast_channel *winner = NULL;
if (outfd)
@@ -817,11 +817,12 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
if (exception)
*exception = 0;
- time(&now);
/* Perform any pending masquerades */
for (x=0;x<n;x++) {
ast_mutex_lock(&c[x]->lock);
if (c[x]->whentohangup) {
+ if (!havewhen)
+ time(&now);
diff = c[x]->whentohangup - now;
if (!havewhen || (diff < whentohangup)) {
havewhen++;
@@ -888,8 +889,12 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
return NULL;
}
+ if (havewhen)
+ time(&now);
for (x=0;x<n;x++) {
c[x]->blocking = 0;
+ if (havewhen && c[x]->whentohangup && (now > c[x]->whentohangup))
+ c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
for (y=0;y<AST_MAX_FDS;y++) {
if (c[x]->fds[y] > -1) {
if ((FD_ISSET(c[x]->fds[y], &rfds) || FD_ISSET(c[x]->fds[y], &efds)) && !winner) {