If ebuild-ipc times out during read, check if the read buffer is
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Sep 2010 23:24:38 +0000 (16:24 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Sep 2010 23:24:38 +0000 (16:24 -0700)
non-empty in order to try to avoid a possible race condition.

bin/ebuild-ipc.py

index 6f17f737b5617f69aebde483231f8a40ae0b76f9..76e64329b05945375c426e1be76d91322dc28f3a 100755 (executable)
@@ -121,6 +121,7 @@ class EbuildIpc(object):
                                        return 2
 
                input_file = None
+               buf = array.array('B')
 
                start_time = time.time()
                while True:
@@ -133,7 +134,6 @@ class EbuildIpc(object):
                                                input_file = open(self.ipc_out_fifo, 'rb', 0)
 
                                        # Read the whole pickle in a single atomic read() call.
-                                       buf = array.array('B')
                                        try:
                                                buf.fromfile(input_file, self._BUFSIZE)
                                        except (EOFError, IOError) as e:
@@ -145,7 +145,9 @@ class EbuildIpc(object):
                                finally:
                                        portage.exception.AlarmSignal.unregister()
                        except portage.exception.AlarmSignal:
-                               if self._daemon_is_alive():
+                               if buf:
+                                       break
+                               elif self._daemon_is_alive():
                                        self._timeout_retry_msg(start_time,
                                                portage.localization._('during read'))
                                else: