From: Pip Cet <pipcet@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 6074@debbugs.gnu.org
Subject: bug#6074: accept-process-output on listening sockets cause non-interruptible infloop
Date: Mon, 22 Jul 2019 17:45:18 +0000 [thread overview]
Message-ID: <CAOqdjBfmSXGRW9VukWe2ARvWVqp=DR59UV11_n0UMTKcu3+iOg@mail.gmail.com> (raw)
In-Reply-To: <83imruqh62.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
On Mon, Jul 22, 2019 at 2:26 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Pip Cet <pipcet@gmail.com>
> > Date: Mon, 22 Jul 2019 03:52:33 +0000
> >
> > diff --git a/src/process.c b/src/process.c
> > index abadabe77e..1311409274 100644
> > --- a/src/process.c
> > +++ b/src/process.c
> > @@ -5277,7 +5277,9 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
> > int nread = read_process_output (proc, wait_proc->infd);
> > if (nread < 0)
> > {
> > - if (errno == EIO || would_block (errno))
> > + if (errno == EINTR)
> > + continue;
> > + else
> > break;
> > }
> > else
>
> Isn't it better to simply call rarely_quit inside the loop?
Why would we try again after receiving EINVAL? I believe the right
behavior is to return immediately in this case, just as we do for EIO.
However, we should probably call rarely_quit inside the loop, anyway,
to catch the case of a kernel bug keeping us busy with EINTRs. How's
this?
[-- Attachment #2: 0001-Don-t-retry-reading-after-receiving-EINVAL-bug-6074.patch --]
[-- Type: text/x-patch, Size: 1060 bytes --]
From a8991ccc1e846aed9a8f1ba0ebcd2771b623f241 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
Date: Mon, 22 Jul 2019 03:49:54 +0000
Subject: [PATCH] Don't retry reading after receiving EINVAL (bug#6074)
* src/process.c (wait_reading_process_output): Don't retry reading
from an fd after an unknown error.
---
src/process.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/process.c b/src/process.c
index abadabe77e..9104a392c8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5270,14 +5270,16 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
/* If data can be read from the process, do so until exhausted. */
if (wait_proc->infd >= 0)
{
+ unsigned int count = 0;
XSETPROCESS (proc, wait_proc);
while (true)
{
int nread = read_process_output (proc, wait_proc->infd);
+ rarely_quit (++count);
if (nread < 0)
{
- if (errno == EIO || would_block (errno))
+ if (errno != EINTR)
break;
}
else
--
2.22.0
next prev parent reply other threads:[~2019-07-22 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-01 22:15 bug#6074: 24.0.50; accept-process-output on listening sockets not incorruptible Helmut Eller
2019-07-22 3:52 ` bug#6074: accept-process-output on listening sockets cause non-interruptible infloop Pip Cet
2019-07-22 14:26 ` Eli Zaretskii
2019-07-22 17:45 ` Pip Cet [this message]
2020-09-14 13:21 ` Lars Ingebrigtsen
2019-07-23 2:46 ` Richard Stallman
2019-07-23 14:31 ` Pip Cet
2019-07-25 3:08 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOqdjBfmSXGRW9VukWe2ARvWVqp=DR59UV11_n0UMTKcu3+iOg@mail.gmail.com' \
--to=pipcet@gmail.com \
--cc=6074@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).