summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-04 15:38:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-05 11:45:18 +0100
commitf71587695c4ced368017f118276807cd3c043ac4 (patch)
tree24226193478627f63a0d10e2291e80512c213305 /bitbake
parent38c05fb8229f48430c64e0735c9e646617b680e4 (diff)
downloadpoky-f71587695c4ced368017f118276807cd3c043ac4.tar.gz
bitbake: server/process: Ensure we don't keep looping if some other server is started
Showing "leftover process" messages when a new server has started and is being used by some UI is horrible. Compare the PID data from the lockfile to avoid this (and the ton of confusing log data it generates). Also, move the time.sleep() call to be after the first lock attempt, which reduces noise in the logs significantly. (Bitbake rev: ce1897a31afb5a14997bc3d2f459b90d43eecb7d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/server/process.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index f794505fd4..83c3e6b444 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -266,6 +266,17 @@ class ProcessServer():
266 # Finally release the lockfile but warn about other processes holding it open 266 # Finally release the lockfile but warn about other processes holding it open
267 lock = self.bitbake_lock 267 lock = self.bitbake_lock
268 lockfile = self.bitbake_lock_name 268 lockfile = self.bitbake_lock_name
269
270 def get_lock_contents(lockfile):
271 try:
272 with open(lockfile, "r") as f:
273 return f.readlines()
274 except FileNotFoundError:
275 return None
276
277 lockcontents = get_lock_contents(lockfile)
278 serverlog("Original lockfile contents: " + str(lockcontents))
279
269 lock.close() 280 lock.close()
270 lock = None 281 lock = None
271 282
@@ -273,14 +284,22 @@ class ProcessServer():
273 i = 0 284 i = 0
274 lock = None 285 lock = None
275 while not lock and i < 30: 286 while not lock and i < 30:
276 time.sleep(0.1)
277 lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False) 287 lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False)
288 if not lock:
289 newlockcontents = get_lock_contents(lockfile)
290 if newlockcontents != lockcontents:
291 # A new server was started, the lockfile contents changed, we can exit
292 serverlog("Lockfile now contains different contents, exiting: " + str(newlockcontents))
293 return
294 time.sleep(0.1)
278 i += 1 295 i += 1
279 if lock: 296 if lock:
280 # We hold the lock so we can remove the file (hide stale pid data) 297 # We hold the lock so we can remove the file (hide stale pid data)
281 # via unlockfile. 298 # via unlockfile.
282 bb.utils.unlockfile(lock) 299 bb.utils.unlockfile(lock)
300 serverlog("Exiting as we could obtain the lock")
283 return 301 return
302
284 if not lock: 303 if not lock:
285 # Some systems may not have lsof available 304 # Some systems may not have lsof available
286 procs = None 305 procs = None