summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-12 16:00:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-12 16:02:11 +0100
commitc4daf38f476c62948aa7c58e83e3281e398cc323 (patch)
tree5c3359b164023a9e9952b65c15d3332d5489dfd9
parent79adf16931f9f7079f98fe7f58c6a67a7723c6c9 (diff)
downloadpoky-c4daf38f476c62948aa7c58e83e3281e398cc323.tar.gz
bitbake: tinfoil: Ensure sockets don't leak even when exceptions occur
We're seeing leaking open socket connections when errors occur and tinfoil is in use. Improve the exception handling so the sockets are closed even if exceptions occur, allowing more robust behaviour when things go wrong. (Bitbake rev: cefbec9ff47ca973a74ec7300cd736f3e0f0bce0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/tinfoil.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 5755e5a346..2fb1bb7d27 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -806,18 +806,22 @@ class Tinfoil:
806 prepare() has been called, or use a with... block when you create 806 prepare() has been called, or use a with... block when you create
807 the tinfoil object which will ensure that it gets called. 807 the tinfoil object which will ensure that it gets called.
808 """ 808 """
809 if self.server_connection: 809 try:
810 self.run_command('clientComplete') 810 if self.server_connection:
811 _server_connections.remove(self.server_connection) 811 try:
812 bb.event.ui_queue = [] 812 self.run_command('clientComplete')
813 self.server_connection.terminate() 813 finally:
814 self.server_connection = None 814 _server_connections.remove(self.server_connection)
815 815 bb.event.ui_queue = []
816 # Restore logging handlers to how it looked when we started 816 self.server_connection.terminate()
817 if self.oldhandlers: 817 self.server_connection = None
818 for handler in self.logger.handlers: 818
819 if handler not in self.oldhandlers: 819 finally:
820 self.logger.handlers.remove(handler) 820 # Restore logging handlers to how it looked when we started
821 if self.oldhandlers:
822 for handler in self.logger.handlers:
823 if handler not in self.oldhandlers:
824 self.logger.handlers.remove(handler)
821 825
822 def _reconvert_type(self, obj, origtypename): 826 def _reconvert_type(self, obj, origtypename):
823 """ 827 """