[asterisk-commits] mmichelson: branch mmichelson/timeout_fixes r373942 - /team/mmichelson/timeou...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 27 13:34:35 CDT 2012
Author: mmichelson
Date: Thu Sep 27 13:34:31 2012
New Revision: 373942
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373942
Log:
Fix the final timeout problem in res_fax.
Modified:
team/mmichelson/timeout_fixes/res/res_fax.c
Modified: team/mmichelson/timeout_fixes/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/timeout_fixes/res/res_fax.c?view=diff&rev=373942&r1=373941&r2=373942
==============================================================================
--- team/mmichelson/timeout_fixes/res/res_fax.c (original)
+++ team/mmichelson/timeout_fixes/res/res_fax.c Thu Sep 27 13:34:31 2012
@@ -1164,6 +1164,8 @@
struct ast_frame *frame = NULL;
struct ast_channel *c = chan;
unsigned int orig_write_format = 0, orig_read_format = 0;
+ int remaining_time;
+ struct timeval start;
chancount = 1;
@@ -1243,7 +1245,9 @@
/* handle frames for the session */
ms = 1000;
- while ((res > -1) && (ms > -1) && (timeout > 0)) {
+ remaining_time = timeout;
+ start = ast_tvnow();
+ while (remaining_time > 0) {
struct ast_channel *ready_chan;
int ofd, exception;
@@ -1260,7 +1264,7 @@
GENERIC_FAX_EXEC_SET_VARS(fax, chan, "HANGUP", "remote channel hungup");
c = NULL;
chancount = 0;
- timeout -= (1000 - ms);
+ remaining_time = ast_remaining_ms(start, timeout);
fax->tech->cancel_session(fax);
if (fax->tech->generate_silence) {
fax->tech->generate_silence(fax);
@@ -1329,7 +1333,8 @@
fax->tech->write(fax, frame);
fax->frames_received++;
}
- timeout = RES_FAX_TIMEOUT;
+ start = ast_tvnow();
+ remaining_time = timeout;
}
ast_frfree(frame);
} else if (ofd == fax->fd) {
@@ -1346,25 +1351,25 @@
ast_write(chan, frame);
fax->frames_sent++;
ast_frfree(frame);
- timeout = RES_FAX_TIMEOUT;
+ start = ast_tvnow();
+ remaining_time = timeout;
} else {
if (ms && (ofd < 0)) {
if ((errno == 0) || (errno == EINTR)) {
- timeout -= (1000 - ms);
- if (timeout <= 0)
+ remaining_time = ast_remaining_ms(start, timeout);
+ if (remaining_time <= 0)
GENERIC_FAX_EXEC_ERROR(fax, chan, "TIMEOUT", "fax session timed-out");
continue;
} else {
ast_log(LOG_WARNING, "something bad happened while channel '%s' was polling.\n", chan->name);
GENERIC_FAX_EXEC_ERROR(fax, chan, "UNKNOWN", "error polling data");
- res = ms;
break;
}
} else {
/* nothing happened */
- if (timeout > 0) {
- timeout -= 1000;
- if (timeout <= 0)
+ if (remaining_time > 0) {
+ remaining_time = ast_remaining_ms(start, timeout);
+ if (remaining_time <= 0)
GENERIC_FAX_EXEC_ERROR(fax, chan, "TIMEOUT", "fax session timed-out");
continue;
} else {
@@ -1375,7 +1380,7 @@
}
}
}
- ast_debug(3, "channel '%s' - event loop stopped { timeout: %d, ms: %d, res: %d }\n", chan->name, timeout, ms, res);
+ ast_debug(3, "channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n", chan->name, timeout, remaining_time);
set_channel_variables(chan, details);
More information about the asterisk-commits
mailing list