Bug #337465 - Make EbuildIpcDaemon._input_handler() use os.read()
authorZac Medico <zmedico@gentoo.org>
Thu, 23 Sep 2010 07:07:08 +0000 (00:07 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 23 Sep 2010 07:07:08 +0000 (00:07 -0700)
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

index adca1b61e6375564712bf536116ba19a37bb32bb..d418fc80a4bfdd36dd7ede7b0471ef92d4765332 100644 (file)
@@ -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: