diff options
authorRichard Purdie <>2017-08-23 15:46:00 +0100
committerRichard Purdie <>2017-08-24 11:19:29 +0100
commitf45196cf84669723382730944dddc7eaf50826f2 (patch)
parentd5cab2dbf5682d2fd08e58316a3bf39a10f63df2 (diff)
process: Clean up connection retry logic
Its possible for a connection to connect to the server as its shutting down but before its removed the socket file. This patch: a) Removes the socket file earlier to avoid connections. b) Handles EOFError in initial connections gracefully. These occur if the socket is closed during the server shutdown. c) Ensure duplicate events aren't shown on the console. This makes debugging these issues very very confusing. With these changes the backtrace that was concerning users is hidden and the server works as expected with a reconnect when it catches it in a bad state. Signed-off-by: Richard Purdie <>
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/bb/ b/lib/bb/
index 0418d52b84..07972f69e5 100755
--- a/lib/bb/
+++ b/lib/bb/
@@ -438,9 +438,10 @@ def setup_bitbake(configParams, configuration, extrafeatures=None):
return None, None
# we start a server with a given configuration"Starting bitbake server...")
- server = bb.server.process.BitBakeServer(lock, sockname, configuration, featureset)
- # The server will handle any events already in the queue
+ # Clear the event queue since we already displayed messages
bb.event.ui_queue = []
+ server = bb.server.process.BitBakeServer(lock, sockname, configuration, featureset)
else:"Reconnecting to bitbake server...")
if not os.path.exists(sockname):
@@ -448,7 +449,13 @@ def setup_bitbake(configParams, configuration, extrafeatures=None):
raise bb.server.process.ProcessTimeout("Bitbake still shutting down as socket exists but no lock?")
if not configParams.server_only:
- server_connection = bb.server.process.connectProcessServer(sockname, featureset)
+ try:
+ server_connection = bb.server.process.connectProcessServer(sockname, featureset)
+ except EOFError:
+ # The server may have been shutting down but not closed the socket yet. If that happened,
+ # ignore it.
+ pass
if server_connection or configParams.server_only:
except (Exception, bb.server.process.ProcessTimeout) as e:
diff --git a/lib/bb/server/ b/lib/bb/server/
index 3ab793c778..fad8aac4da 100644
--- a/lib/bb/server/
+++ b/lib/bb/server/
@@ -215,6 +215,10 @@ class ProcessServer(multiprocessing.Process):
ready = self.idle_commands(.1, fds)
+ # Remove the socket file so we don't get any more connections to avoid races
+ os.unlink(self.sockname)
+ self.sock.close()
@@ -222,10 +226,6 @@ class ProcessServer(multiprocessing.Process):
- # Remove the socket file so we don't get any more connections to avoid races
- os.unlink(self.sockname)
- self.sock.close()
# Finally release the lockfile but warn about other processes holding it open
lock = self.bitbake_lock
lockfile =