[bitbake-devel] build: defer processing of cleandirs until after lockfiles are acquired

Submitted by Chris Laplante via lists.openembedded.org on Sept. 29, 2020, 3:14 p.m. | Patch ID: 176886

Details

Message ID 20200929151437.101901-1-chris.laplante@agilent.com
State New
Headers show

Commit Message

Chris Laplante via lists.openembedded.org Sept. 29, 2020, 3:14 p.m.
This is to avoid potential races for tasks that use both [cleandirs] and
[lockfiles].

It is currently believed that normal [dirs] handling is fine as-is.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 lib/bb/build.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/bb/build.py b/lib/bb/build.py
index 974d2ff0..51bcad96 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -188,11 +188,6 @@  def exec_func(func, d, dirs = None):
         oldcwd = None
 
     flags = d.getVarFlags(func)
-    cleandirs = flags.get('cleandirs') if flags else None
-    if cleandirs:
-        for cdir in d.expand(cleandirs).split():
-            bb.utils.remove(cdir, True)
-            bb.utils.mkdirhier(cdir)
 
     if flags and dirs is None:
         dirs = flags.get('dirs')
@@ -250,6 +245,12 @@  def exec_func(func, d, dirs = None):
                 pass
 
     with bb.utils.fileslocked(lockfiles):
+        cleandirs = flags.get('cleandirs') if flags else None
+        if cleandirs:
+            for cdir in d.expand(cleandirs).split():
+                bb.utils.remove(cdir, True)
+                bb.utils.mkdirhier(cdir)
+
         if ispython:
             exec_func_python(func, d, runfile, cwd=adir)
         else: