From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH 2/2] libxl: Cope with pipes which signal POLLHUP|POLLIN on read eof Date: Wed, 8 Apr 2015 12:05:03 +0100 Message-ID: <20150408110503.GH30811@zion.uk.xensource.com> References: <21795.54797.502271.384422@mariner.uk.xensource.com> <1428411928-19990-1-git-send-email-ian.jackson@eu.citrix.com> <1428411928-19990-2-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1428411928-19990-2-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel@lists.xensource.com, Wei Liu , Ian Campbell , Andrew Cooper , Ross Lagerwall , Roger Pau =?iso-8859-1?Q?Monn=E9?= List-Id: xen-devel@lists.xenproject.org On Tue, Apr 07, 2015 at 02:05:28PM +0100, Ian Jackson wrote: > Some operating systems (including Linux and FreeBSD[1]) signal not > (only) POLLIN when a reading pipe reaches EOF, but POLLHUP (with or > without POLLIN). This is permitted[2]. The implications are that in > the general case it is not possible to determine whether POLLHUP > indicates an error or simply eof without attempting a read. > = > Datacopiers mishandle this, because they always treat POLLHUP > exceptionally (either reporting it via callback_pollhup, or treating > it as an error). datacopiers reading from pipes on such OSs can fail > (perhaps leaving some data unprocessed) rather than completing > successfully. > = > [1] http://www.greenend.org.uk/rjk/tech/poll.html > [2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html > = > Distinguishing POLLHUP is needed for pty fds, but most callers in > libxl do not care about POLLHUP except as an error or eof condition. > = > So change the datacopier semantics so that if callback_pollhup is not > specified we treat POLLHUP almost like POLLIN. The difference is that > if we get HUP from poll, but EWOULDBLOCK from read, we must signal an > error ratehr than attempting the read again. > = > This fixes the problem which 7e9ec50b0535 was aimed at. > = > Signed-off-by: Ian Jackson > CC: Ian Campbell > CC: Andrew Cooper > CC: Roger Pau Monn=E9 > CC: Ross Lagerwall > CC: Wei Liu The code matches documents and commit log so: Acked-by: Wei Liu