From: Ian Campbell Subject: Re: [PATCH 24/29] tools/libxl: Allow suppression of POLLHUP for datacopiers Date: Thu, 11 Sep 2014 13:05:13 +0100 Message-ID: <1410437113.25388.6.camel@kazak.uk.xensource.com> References: <1410369067-1330-1-git-send-email-andrew.cooper3@citrix.com> <1410369067-1330-25-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1410369067-1330-25-git-send-email-andrew.cooper3@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: Andrew Cooper Cc: Ian Jackson , Xen-devel List-Id: xen-devel@lists.xenproject.org On Wed, 2014-09-10 at 18:11 +0100, Andrew Cooper wrote: > If the far end of a pipe has been closed, poll() will set POLLHUP. When > reading from a pipe, POLLIN|POLLHUP is a valid state, even when there is still > data to be read. > > Currently, datacopier will bail because of POLLHUP before discovering that > there is valid data to be read. > > Add an option to ignore POLLHUP for consumers who would prefer to read to EOF. > Signed-off-by: Andrew Cooper > CC: Ian Campbell > CC: Ian Jackson > > --- > > It might be easier/better to alter the POLLHUP handling, but I am struggling > to work out what effect that would have on the bootloader pty handling. I was just about to ask why you weren't doing this. I'll leave the answer to Ian. > --- > tools/libxl/libxl_aoutils.c | 2 +- > tools/libxl/libxl_internal.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c > index 9183716..2b39432 100644 > --- a/tools/libxl/libxl_aoutils.c > +++ b/tools/libxl/libxl_aoutils.c > @@ -207,7 +207,7 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev, > if (datacopier_pollhup_handled(egc, dc, revents, 0)) > return; > > - if (revents & ~POLLIN) { > + if (revents & ~(POLLIN | (dc->suppress_pollhup ? POLLHUP : 0))) { > LOG(ERROR, "unexpected poll event 0x%x (should be POLLIN)" > " on %s during copy of %s", revents, dc->readwhat, dc->copywhat); > datacopier_callback(egc, dc, -1, 0); > diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h > index 056843a..537b523 100644 > --- a/tools/libxl/libxl_internal.h > +++ b/tools/libxl/libxl_internal.h > @@ -2431,6 +2431,7 @@ struct libxl__datacopier_state { > FILE *log; /* gets a copy of everything */ > libxl__datacopier_callback *callback; > libxl__datacopier_callback *callback_pollhup; > + int suppress_pollhup; > /* remaining fields are private to datacopier */ > libxl__ev_fd toread, towrite; > ssize_t used;