|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 24/29] tools/libxl: Allow suppression of POLLHUP for datacopiers
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 <andrew.cooper3@xxxxxxxxxx>
> CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
> CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
>
> ---
>
> 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;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |