Add a filelock for in-place case
Multiple bpmodify process on the same Android.bp can run in parallel in the case of aidl-freeze-api. So, add a file lock for in-place editing case(-w) Bug: 229413853 Test: run bpmodify in parallel and check result Change-Id: I5368b0304b59f34fff60025120b38cc5f615ac40
This commit is contained in:
parent
5208ee885c
commit
28c7996f2c
1 changed files with 6 additions and 0 deletions
|
@ -15,6 +15,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/google/blueprint/parser"
|
"github.com/google/blueprint/parser"
|
||||||
|
@ -68,6 +69,11 @@ func processFile(filename string, in io.Reader, out io.Writer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
if *write {
|
||||||
|
syscall.Flock(int(f.Fd()), syscall.LOCK_EX)
|
||||||
|
}
|
||||||
|
|
||||||
in = f
|
in = f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue