wrap: Lock subproject directory when downloading wraps

To avoid raceconditions, where one instance of meson currently downloads
a subproject defined in a wrapfile, while another either
  a. starts the download itself too
  b. attemts to evaluate the partially downloaded subproject
wraplock introduces a lockfile, which should prevent simultaneous access
of subprojects by wrap between different instances of meson.
pull/13854/head
Florian "sp1rit"​ 4 months ago
parent 43254a5e55
commit 1ff4a2fa6d
No known key found for this signature in database
GPG Key ID: B1F4055D8460CE34
  1. 13
      mesonbuild/wrap/wrap.py

@ -29,7 +29,10 @@ from functools import lru_cache
from . import WrapMode
from .. import coredata
from ..mesonlib import quiet_git, GIT, ProgressBar, MesonException, windows_proof_rmtree, Popen_safe
from ..mesonlib import (
DirectoryLock, DirectoryLockAction, quiet_git, GIT, ProgressBar, MesonException,
windows_proof_rmtree, Popen_safe
)
from ..interpreterbase import FeatureNew
from ..interpreterbase import SubProject
from .. import mesonlib
@ -432,7 +435,7 @@ class Resolver:
return wrap_name
return None
def resolve(self, packagename: str, force_method: T.Optional[Method] = None) -> T.Tuple[str, Method]:
def _resolve(self, packagename: str, force_method: T.Optional[Method] = None) -> T.Tuple[str, Method]:
wrap = self.wraps.get(packagename)
if wrap is None:
wrap = self.get_from_wrapdb(packagename)
@ -530,6 +533,12 @@ class Resolver:
self.wrap.update_hash_cache(self.dirname)
return rel_path, method
def resolve(self, packagename: str, force_method: T.Optional[Method] = None) -> T.Tuple[str, Method]:
with DirectoryLock(self.subdir_root, '.wraplock',
DirectoryLockAction.WAIT,
'Failed to lock subprojects directory'):
return self._resolve(packagename, force_method)
def check_can_download(self) -> None:
# Don't download subproject data based on wrap file if requested.
# Git submodules are ok (see above)!

Loading…
Cancel
Save