mirror of
https://github.com/golang/go.git
synced 2026-02-07 02:09:55 +00:00
os: fix Root.MkdirAll to handle race of directory creation
No tests were added, because in order to reproduce, the directory would have to be created precisely between the rootOpenDir and mkdirat calls, which is impossible to do in a test. Fixes #75114 Change-Id: I6f86a5b33c87452c35728318eaf2169a7534ef37 Reviewed-on: https://go-review.googlesource.com/c/go/+/698215 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Sean Liao <sean@liao.dev>
This commit is contained in:
parent
98238fd495
commit
a076f49757
1 changed files with 3 additions and 1 deletions
|
|
@ -131,7 +131,9 @@ func rootMkdirAll(r *Root, fullname string, perm FileMode) error {
|
|||
if try > 0 || !IsNotExist(err) {
|
||||
return 0, &PathError{Op: "openat", Err: err}
|
||||
}
|
||||
if err := mkdirat(parent, name, perm); err != nil {
|
||||
// Try again on EEXIST, because the directory may have been created
|
||||
// by another process or thread between the rootOpenDir and mkdirat calls.
|
||||
if err := mkdirat(parent, name, perm); err != nil && err != syscall.EEXIST {
|
||||
return 0, &PathError{Op: "mkdirat", Err: err}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue