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-30 08:43:36 +0100 |
commit | 07cee9dea1ad3408a49e4b9d9f5318474ddfa60b (patch) | |
tree | 716bc34d7de4192bfcdaeac63a7e5dc9888145fb /bitbake | |
parent | b2c39835bb61687220abbef72e4f69a272cf8afb (diff) | |
download | poky-07cee9dea1ad3408a49e4b9d9f5318474ddfa60b.tar.gz |
bitbake: process: Don't leak open pipes upon reconnection
If we reconnect to the server, stop leaking pipes and clean up
after ourselves.
(Bitbake rev: f41e4e971e807157be68cf4496580494b8b60643)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/server/process.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index 6106c07380..3530bdc07e 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py | |||
@@ -420,7 +420,11 @@ def connectProcessServer(sockname, featureset): | |||
420 | finally: | 420 | finally: |
421 | os.chdir(cwd) | 421 | os.chdir(cwd) |
422 | 422 | ||
423 | readfd = writefd = readfd1 = writefd1 = readfd2 = writefd2 = None | ||
424 | eq = command_chan_recv = command_chan = None | ||
425 | |||
423 | try: | 426 | try: |
427 | |||
424 | # Send an fd for the remote to write events to | 428 | # Send an fd for the remote to write events to |
425 | readfd, writefd = os.pipe() | 429 | readfd, writefd = os.pipe() |
426 | eq = BBUIEventQueue(readfd) | 430 | eq = BBUIEventQueue(readfd) |
@@ -435,9 +439,22 @@ def connectProcessServer(sockname, featureset): | |||
435 | 439 | ||
436 | server_connection = BitBakeProcessServerConnection(command_chan, command_chan_recv, eq, sock) | 440 | server_connection = BitBakeProcessServerConnection(command_chan, command_chan_recv, eq, sock) |
437 | 441 | ||
442 | # Close the ends of the pipes we won't use | ||
443 | for i in [writefd, readfd1, writefd2]: | ||
444 | os.close(i) | ||
445 | |||
438 | server_connection.connection.updateFeatureSet(featureset) | 446 | server_connection.connection.updateFeatureSet(featureset) |
439 | 447 | ||
440 | except: | 448 | except (Exception, SystemExit) as e: |
449 | if command_chan_recv: | ||
450 | command_chan_recv.close() | ||
451 | if command_chan: | ||
452 | command_chan.close() | ||
453 | for i in [writefd, readfd1, writefd2]: | ||
454 | try: | ||
455 | os.close(i) | ||
456 | except OSError: | ||
457 | pass | ||
441 | sock.close() | 458 | sock.close() |
442 | raise | 459 | raise |
443 | 460 | ||