summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-26 00:04:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-26 09:05:38 +0100
commit8ecde1aa8fd1d23945c7e0edfd4921ab9707169a (patch)
tree89a901e796be86b894a14f5944c3a869b7c4b6e3 /bitbake/lib
parent77441a08d4ba27996a651651e65f63af76e2503e (diff)
downloadpoky-8ecde1aa8fd1d23945c7e0edfd4921ab9707169a.tar.gz
bitbake: process: Avoid bb.utils.timeout
I have a suspicion based on process traces that the flock() call is no longer interrupted by SIGALRM and hence the timeout doesn't work. We were relying on EINTR triggering around syscalls but python is likely protecting us from that in modern versions. Re-implement this code with a different mechanism which doesn't have that potential issue. (Bitbake rev: 8eb52afdfd4c3e6478d4f8cc56e99def3f1c924c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/server/process.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 6d936ed457..973bc45251 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -266,34 +266,37 @@ class ProcessServer():
266 lock = None 266 lock = None
267 267
268 while not lock: 268 while not lock:
269 with bb.utils.timeout(3): 269 i = 0
270 lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=True) 270 lock = None
271 if lock: 271 while not lock and i < 30:
272 # We hold the lock so we can remove the file (hide stale pid data) 272 time.sleep(0.1)
273 # via unlockfile. 273 _, lock = bb.utils.lockfile(lockfile, shared=False, retry=False, block=False)
274 bb.utils.unlockfile(lock) 274 i += 1
275 return 275 if lock:
276 276 # We hold the lock so we can remove the file (hide stale pid data)
277 if not lock: 277 # via unlockfile.
278 # Some systems may not have lsof available 278 bb.utils.unlockfile(lock)
279 procs = None 279 return
280 if not lock:
281 # Some systems may not have lsof available
282 procs = None
283 try:
284 procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT)
285 except OSError as e:
286 if e.errno != errno.ENOENT:
287 raise
288 if procs is None:
289 # Fall back to fuser if lsof is unavailable
280 try: 290 try:
281 procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) 291 procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT)
282 except OSError as e: 292 except OSError as e:
283 if e.errno != errno.ENOENT: 293 if e.errno != errno.ENOENT:
284 raise 294 raise
285 if procs is None: 295
286 # Fall back to fuser if lsof is unavailable 296 msg = "Delaying shutdown due to active processes which appear to be holding bitbake.lock"
287 try: 297 if procs:
288 procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) 298 msg += ":\n%s" % str(procs)
289 except OSError as e: 299 print(msg)
290 if e.errno != errno.ENOENT:
291 raise
292
293 msg = "Delaying shutdown due to active processes which appear to be holding bitbake.lock"
294 if procs:
295 msg += ":\n%s" % str(procs)
296 print(msg)
297 300
298 def idle_commands(self, delay, fds=None): 301 def idle_commands(self, delay, fds=None):
299 nextsleep = delay 302 nextsleep = delay