bitbake: utils: Handle lockfile filenames that are too long for filesystems

The fetcher mirror code can go crazy creating lock filenames which exceed the
filesystem limits. When this happens, the code will loop/hang.

Handle the filename too long exception correctly but also truncate lockfile
lengths to under 256 since the worst case situation is lockfile overlap
and lack of parallelism.

(Bitbake rev: 315599b5b3ca0f1c797555db2460081681b6c945)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 63baf3440b16e41ac6601de21ced94a94bdf1509)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2021-12-03 22:25:46 +08:00
parent 69a7c15825
commit 7edd2be25f

View File

@ -451,6 +451,10 @@ def lockfile(name, shared=False, retry=True, block=False):
consider the possibility of sending a signal to the process to break
out - at which point you want block=True rather than retry=True.
"""
if len(name) > 255:
root, ext = os.path.splitext(name)
name = root[:255 - len(ext)] + ext
dirname = os.path.dirname(name)
mkdirhier(dirname)
@ -487,7 +491,7 @@ def lockfile(name, shared=False, retry=True, block=False):
return lf
lf.close()
except OSError as e:
if e.errno == errno.EACCES:
if e.errno == errno.EACCES or e.errno == errno.ENAMETOOLONG:
logger.error("Unable to acquire lock '%s', %s",
e.strerror, name)
sys.exit(1)