From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 23 Aug 2010 07:35:43 +0000 (+0200)
Subject: poll, select: handle ERROR_BROKEN_PIPE.
X-Git-Tag: v0.1~3922
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=51c2a23373ee3583682e6faae3dc4f518bd03f04;p=gnulib.git

poll, select: handle ERROR_BROKEN_PIPE.

* lib/poll.c (win32_compute_revents): Return POLLHUP when
PeekNamedPipe fails with ERROR_BROKEN_PIPE.
* lib/select.c (win32_compute_revents): Do not mark a pipe
as writeable if PeekNamedPipe fails with ERROR_BROKEN_PIPE.
---

diff --git a/ChangeLog b/ChangeLog
index 1337347344..7a0851099b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-08-22  Paolo Bonzini  <bonzini@gnu.org>
+	    Erik Faye-Lund <kusmabite@gmail.com>
+
+	poll, select: handle ERROR_BROKEN_PIPE.
+	* lib/poll.c (win32_compute_revents): Return POLLHUP when
+	PeekNamedPipe fails with ERROR_BROKEN_PIPE.
+	* lib/select.c (win32_compute_revents): Do not mark a pipe
+	as writeable if PeekNamedPipe fails with ERROR_BROKEN_PIPE.
+
 2010-08-22  Giuseppe Scrivano  <gscrivano@gnu.org>
 
 	fts: allow compilation with C++
diff --git a/lib/poll.c b/lib/poll.c
index 49c41591ef..aeb7a356fc 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
         {
diff --git a/lib/select.c b/lib/select.c
index 5677fdd478..bc02266428 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -132,6 +132,8 @@ win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits,
           if (avail)
             read = TRUE;
         }
+      else if (GetLastError () == ERROR_BROKEN_PIPE)
+        ;
 
       else
         {