On Thu, 2015-04-02 at 16:04 +0100, Ian Jackson wrote: > When the bootloader exits, several things change, all at once: > (a) The master pty fd (held by libxl) starts to signal POLLHUP > and maybe also POLLIN. > (b) The child exits (so that the SIGCHLD self-pipe signals POLLIN, > which will be handled by the libxl child process code. > (c) reads on the master pty fd start to return EOF > > From the point of view of the datacopier these might happen in any > order. > > (c) can be detected only after a previous POLLIN without POLLHUP and > that previous POLLIN would be associated with data which was read, > which must therefore have ended up in the dc's buffer. But nothing > stops the dc from writing that data into the output fd and reporting > eof before it calls poll again. > > This race is unlikely. Indeed it might be actually 100% precluded, by > luck, by the current organisation of the fd handling code. But > nevertheless it should be fixed. > > We solve the race with a poll of the reading fd, to double-check, when > we detect eof via read. (This is only necessary if the caller has > specified callback_pollhup, as otherwise POLLHUP|POLLIN - and, > presumably, POLLIN followed perhaps by POLLHUP|POLLIN, is to be > treated as eof anyway.) > > Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com> > CC: Andrew Cooper <andrew.coop...@citrix.com> > CC: Roger Pau Monné <roger....@citrix.com>
Acked-by: Ian Campbell <ian.campb...@citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel