diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-22 19:53:30 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-22 19:53:30 +0000 |
commit | a3794b65b87cf7e0c2ac0de816446c369f522966 (patch) | |
tree | ce62323981149d7ac8d619728686a793961b473e /res | |
parent | 7cb9ccbb92d63e9f186aeaa8953516070d3014c5 (diff) |
Juggie in #asterisk-dev was reporting problems where fgets would return
without reading the whole line when using fastagi. When this happens,
errno was set to EINTR or EAGAIN. This patch accounts for the possibility
and lets fgets continue in that case.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@80360 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_agi.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index e1c96b04b..d0ae40817 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1866,8 +1866,14 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi ast_frfree(f); } } else if (outfd > -1) { + size_t len; retry = RETRY; - if (!fgets(buf, sizeof(buf), readf)) { + buf[0] = '\0'; +retry_fgets: + len = strlen(buf); + if (!fgets(buf + len, sizeof(buf) - len, readf)) { + if (!feof(readf) && (errno == EINTR || errno == EAGAIN)) + goto retry_fgets; /* Program terminated */ if (returnstatus) returnstatus = -1; @@ -1879,6 +1885,8 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi pid = -1; break; } + if (errno == EINTR || errno == EAGAIN) + goto retry_fgets; /* get rid of trailing newline, if any */ if (*buf && buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = 0; |