[oe-commits] Randy Witt : qemurunner: Don't loop on EWOULDBLOCK in logging thread.

git at git.openembedded.org git at git.openembedded.org
Sat Aug 29 12:39:33 UTC 2015


Module: openembedded-core.git
Branch: master
Commit: 3aad1f489f38e999914ee6ccbf87367b9a75ee5e
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=3aad1f489f38e999914ee6ccbf87367b9a75ee5e

Author: Randy Witt <randy.e.witt at linux.intel.com>
Date:   Thu Aug 27 02:04:10 2015 -0700

qemurunner: Don't loop on EWOULDBLOCK in logging thread.

EAGAIN/EWOULDBLOCK can be followed by no data. So don't tight loop
waiting for data.

Signed-off-by: Randy Witt <randy.e.witt at linux.intel.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/lib/oeqa/utils/qemurunner.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 6d36df6..bcdb69b 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -139,6 +139,7 @@ class QemuRunner:
                 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, getOutput(output)))
                 self.stop()
                 return False
+            logger.info("qemu cmdline used:\n{}".format(cmdline))
             logger.info("Target IP: %s" % self.ip)
             logger.info("Server IP: %s" % self.server_ip)
 
@@ -368,6 +369,7 @@ class LoggingThread(threading.Thread):
             os.write(self.writepipe, "stop")
 
     def teardown(self):
+        self.logger.info("Tearing down logging thread")
         self.close_socket(self.serversock)
 
         if self.readsock is not None:
@@ -412,25 +414,23 @@ class LoggingThread(threading.Thread):
 
                 # Actual data to be logged
                 elif self.readsock.fileno() == event[0]:
-                    data = self.recv_loop()
+                    data = self.recv(1024)
                     self.logfunc(data)
 
     # Since the socket is non-blocking make sure to honor EAGAIN
-    # and EWOULDBLOCK
-    def recv_loop(self):
-        while True:
-            try:
-                data = self.readsock.recv(1024)
-                break
-            except socket.error as e:
-                if e.errno == errno.EAGAIN or e.errno == errno.EWOULDBLOCK:
-                    continue
-                else:
-                    raise
+    # and EWOULDBLOCK.
+    def recv(self, count):
+        try:
+            data = self.readsock.recv(count)
+        except socket.error as e:
+            if e.errno == errno.EAGAIN or e.errno == errno.EWOULDBLOCK:
+                return ''
+            else:
+                raise
 
-        if not data:
+        if data is None:
             raise Exception("No data on read ready socket")
-        elif data == 0:
+        elif not data:
             # This actually means an orderly shutdown
             # happened. But for this code it counts as an
             # error since the connection shouldn't go away



More information about the Openembedded-commits mailing list