summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server/process.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/server/process.py')
-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