From: Zac Medico Date: Fri, 16 Dec 2011 18:58:35 +0000 (-0800) Subject: Fix EIO handling for PollSelectAdapter. X-Git-Tag: v2.2.0_alpha82~59 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=36632047bebbd435610944ad9e7850163b260645;p=portage.git Fix EIO handling for PollSelectAdapter. In PipeReader and AbstractPollTask, we have to treat EIO as EOF, in order to terminate the select loop at the correct time when using PollSelectAdapter. This fixes a regression in EIO handling since commits 915348ce34fc499ac295b8f0ffee9f0829803542 adn 30d2d0a9db486c5a70848ad5d27b37a3ec48f271. --- diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py index ea13587bc..d4785a2a1 100644 --- a/pym/_emerge/AbstractPollTask.py +++ b/pym/_emerge/AbstractPollTask.py @@ -50,9 +50,14 @@ class AbstractPollTask(AsynchronousTask): except OSError as e: # EIO happens with pty on Linux after the # slave end of the pty has been closed. - if e.errno not in (errno.EAGAIN, errno.EIO): + if e.errno == errno.EIO: + # EOF: return empty buffer + pass + elif e.errno == errno.EAGAIN: + # EAGAIN: return None + buf = None + else: raise - buf = None return buf diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index 78acb72df..a465c2a28 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -66,9 +66,14 @@ class PipeReader(AbstractPollTask): except OSError as e: # EIO happens with pty on Linux after the # slave end of the pty has been closed. - if e.errno not in (errno.EAGAIN, errno.EIO): + if e.errno == errno.EIO: + self._unregister() + self.wait() + break + elif e.errno == errno.EAGAIN: + break + else: raise - break else: if data: self._read_data.append(data)