]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Juggie in #asterisk-dev was reporting problems where fgets would return
authorRussell Bryant <russell@russellbryant.com>
Wed, 22 Aug 2007 19:53:30 +0000 (19:53 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 22 Aug 2007 19:53:30 +0000 (19:53 +0000)
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: https://origsvn.digium.com/svn/asterisk/branches/1.4@80360 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_agi.c

index e1c96b04b0504d61a53dc12a578a654876a22a73..d0ae40817321b1a1030094ff2c29e8523e0aaf0f 100644 (file)
@@ -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;