[oe-commits] [bitbake] 01/01: process: Improve client disconnects

git at git.openembedded.org git at git.openembedded.org
Mon Aug 14 10:18:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

commit 5e267f14bb0155889615f567a920af4a37eb3c6b
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Sun Aug 13 23:32:30 2017 +0100

    process: Improve client disconnects
    
    There have been cases where the server could loop indefinitely and incorrectly
    handle client disconnects. In the EOFError case, ensure a full disconnect
    happens in the alternative disconnect path to avoid this.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/server/process.py | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index ee8b14e..a7a6fbf 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -134,6 +134,26 @@ class ProcessServer(multiprocessing.Process):
         if self.xmlrpc:
             fds.append(self.xmlrpc)
         print("Entering server connection loop")
+
+        def disconnect_client(self, fds):
+            if not self.haveui:
+                return
+            print("Disconnecting Client")
+            fds.remove(self.controllersock)
+            fds.remove(self.command_channel)
+            bb.event.unregister_UIHhandler(self.event_handle, True)
+            self.command_channel_reply.writer.close()
+            self.event_writer.writer.close()
+            del self.event_writer
+            self.controllersock.close()
+            self.controllersock = False
+            self.haveui = False
+            self.lastui = time.time()
+            self.cooker.clientComplete()
+            if self.timeout is None:
+                print("No timeout, exiting.")
+                self.quit = True
+
         while not self.quit:
             if self.sock in ready:
                 self.controllersock, address = self.sock.accept()
@@ -165,21 +185,8 @@ class ProcessServer(multiprocessing.Process):
                     self.haveui = True
 
                 except (EOFError, OSError):
-                    print("Disconnecting Client")
-                    fds.remove(self.controllersock)
-                    fds.remove(self.command_channel)
-                    bb.event.unregister_UIHhandler(self.event_handle, True)
-                    self.command_channel_reply.writer.close()
-                    self.event_writer.writer.close()
-                    del self.event_writer
-                    self.controllersock.close()
-                    self.controllersock = False
-                    self.haveui = False
-                    self.lastui = time.time()
-                    self.cooker.clientComplete()
-                    if self.timeout is None:
-                        print("No timeout, exiting.")
-                        self.quit = True
+                    disconnect_client(self, fds)
+
             if not self.timeout == -1.0 and not self.haveui and self.lastui and self.timeout and \
                     (self.lastui + self.timeout) < time.time():
                 print("Server timeout, exiting.")
@@ -191,6 +198,7 @@ class ProcessServer(multiprocessing.Process):
                 except EOFError:
                     # Client connection shutting down
                     ready = []
+                    disconnect_client(self, fds)
                     continue
                 if command[0] == "terminateServer":
                     self.quit = True

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list