From: Zac Medico Date: Thu, 23 Sep 2010 07:07:08 +0000 (-0700) Subject: Bug #337465 - Make EbuildIpcDaemon._input_handler() use os.read() X-Git-Tag: v2.2_rc87~18 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0d7eb266a9d7909591817e4fd899c1c2ab07b53c;p=portage.git Bug #337465 - Make EbuildIpcDaemon._input_handler() use os.read() since array.fromfile() and file.read() are both known to erroneously return an empty string from this non-blocking fifo stream on FreeBSD. --- diff --git a/pym/_emerge/EbuildIpcDaemon.py b/pym/_emerge/EbuildIpcDaemon.py index adca1b61e..d418fc80a 100644 --- a/pym/_emerge/EbuildIpcDaemon.py +++ b/pym/_emerge/EbuildIpcDaemon.py @@ -3,7 +3,9 @@ import errno import pickle +from portage import os from _emerge.FifoIpcDaemon import FifoIpcDaemon +from _emerge.PollConstants import PollConstants class EbuildIpcDaemon(FifoIpcDaemon): """ @@ -28,12 +30,18 @@ class EbuildIpcDaemon(FifoIpcDaemon): def _input_handler(self, fd, event): # Read the whole pickle in a single atomic read() call. - buf = self._read_buf(self._files.pipe_in, event) + data = None + if event & PollConstants.POLLIN: + # For maximum portability, use os.read() here since + # array.fromfile() and file.read() are both known to + # erroneously return an empty string from this + # non-blocking fifo stream on FreeBSD (bug #337465). + data = os.read(fd, self._bufsize) - if buf: + if data: try: - obj = pickle.loads(buf.tostring()) + obj = pickle.loads(data) except SystemExit: raise except Exception: