diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-28 15:42:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-28 23:02:32 +0100 |
commit | f41e4e971e807157be68cf4496580494b8b60643 (patch) | |
tree | fa89f7200db05e2ea195bedd368beb2b4e1a6e53 | |
parent | 57000d44beb1aeba37dfc70782b0d6418943acc5 (diff) | |
download | bitbake-contrib-f41e4e971e807157be68cf4496580494b8b60643.tar.gz |
process: Don't leak open pipes upon reconnection
If we reconnect to the server, stop leaking pipes and clean up
after ourselves.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/server/process.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py index 6106c0738..3530bdc07 100644 --- a/lib/bb/server/process.py +++ b/lib/bb/server/process.py @@ -420,7 +420,11 @@ def connectProcessServer(sockname, featureset): finally: os.chdir(cwd) + readfd = writefd = readfd1 = writefd1 = readfd2 = writefd2 = None + eq = command_chan_recv = command_chan = None + try: + # Send an fd for the remote to write events to readfd, writefd = os.pipe() eq = BBUIEventQueue(readfd) @@ -435,9 +439,22 @@ def connectProcessServer(sockname, featureset): server_connection = BitBakeProcessServerConnection(command_chan, command_chan_recv, eq, sock) + # Close the ends of the pipes we won't use + for i in [writefd, readfd1, writefd2]: + os.close(i) + server_connection.connection.updateFeatureSet(featureset) - except: + except (Exception, SystemExit) as e: + if command_chan_recv: + command_chan_recv.close() + if command_chan: + command_chan.close() + for i in [writefd, readfd1, writefd2]: + try: + os.close(i) + except OSError: + pass sock.close() raise |