bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lib/poll.c, win32 SIGHUP on pipes


From: Paolo Bonzini
Subject: Re: lib/poll.c, win32 SIGHUP on pipes
Date: Mon, 23 Aug 2010 08:05:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5

On 08/23/2010 01:30 AM, Erik Faye-Lund wrote:
On Mon, Aug 23, 2010 at 12:32 AM, Erik Faye-Lund<address@hidden>  wrote:
I've recently looked into replacing the poll-emulation in Git for
Windows with the code from gnulib, due to the improved pipe-support in
gnulib.

However, I've noticed that win32_compute_revents() never returns
SIGHUP for FILE_TYPE_PIPE, which is something the code I'm trying to
port currently depends on. What seems to happen is the following: one
of the pipe-ends is closed, and thus PeekNamedPipe() fails.
win32_compute_revents() mistakenly believes that the failure means
that the pipe can be written because NtQueryInformationFile succeeds
and returns 8192 for both fpli.WriteQuotaAvailable and
fpli.OutboundQuota.

In my case, a simple "happened |= POLLHUP;"-hack in the error-case
solves the issue in this particular case, but this is obviously not
correct in the general case.

My guess is that a proper solution would be to find device a robust
way of checking if a pipe is closed or not. I haven't looked much into
this yet, but at least GetNamedPipeInfo() doesn't seem to error out on
my pipe.


The following seems to work:

diff --git a/lib/poll.c b/lib/poll.c
index 49c4159..83532c4 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -150,6 +150,8 @@ win32_compute_revents (HANDLE h, int *p_sought)
            if (avail)
              happened |= *p_sought&  (POLLIN | POLLRDNORM);
          }
+      else if (GetLastError() == ERROR_BROKEN_PIPE)
+        happened |= POLLHUP;

        else
          {

Thanks, makes sense.  I'll apply the patch.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]