From 0d7eb266a9d7909591817e4fd899c1c2ab07b53c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 23 Sep 2010 00:07:08 -0700 Subject: 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. --- pym/_emerge/EbuildIpcDaemon.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pym') 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: -- cgit v1.2.3-1-g7c22