From b829d1b5eb486786cae088f6927530433a7e08e8 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 29 Nov 2018 16:51:18 +0000 Subject: server/process: Make lockfile handling clearer This simplifies the code and makes it easier to read but has the same functionality. Signed-off-by: Richard Purdie --- lib/bb/server/process.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py index 42d79079a..7cb08d5c8 100644 --- a/lib/bb/server/process.py +++ b/lib/bb/server/process.py @@ -239,6 +239,12 @@ class ProcessServer(multiprocessing.Process): while not lock: with bb.utils.timeout(3): lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=True) + if lock: + # We hold the lock so we can remove the file (hide stale pid data) + bb.utils.remove(lockfile) + bb.utils.unlockfile(lock) + return + if not lock: # Some systems may not have lsof available procs = None @@ -259,10 +265,6 @@ class ProcessServer(multiprocessing.Process): if procs: msg += ":\n%s" % str(procs) print(msg) - return - # We hold the lock so we can remove the file (hide stale pid data) - bb.utils.remove(lockfile) - bb.utils.unlockfile(lock) def idle_commands(self, delay, fds=None): nextsleep = delay -- cgit 1.2.3-korg