mirror of
https://github.com/golang/go
synced 2024-11-18 03:14:44 -07:00
os: touch up the EINTR retry loop in OpenFile
In particular, don't use goto and do restrict the behavior to darwin. This addresses comments from http://golang.org/cl/14484. Change-Id: I5b99e1762d1c5b27fdd12b72a5c6d981f6a92f0f Reviewed-on: https://go-review.googlesource.com/14673 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
001a75a74c
commit
e7e2739849
@ -90,14 +90,19 @@ func OpenFile(name string, flag int, perm FileMode) (*File, error) {
|
||||
}
|
||||
}
|
||||
|
||||
retry:
|
||||
r, e := syscall.Open(name, flag|syscall.O_CLOEXEC, syscallMode(perm))
|
||||
if e != nil {
|
||||
var r int
|
||||
for {
|
||||
var e error
|
||||
r, e = syscall.Open(name, flag|syscall.O_CLOEXEC, syscallMode(perm))
|
||||
if e == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// On OS X, sigaction(2) doesn't guarantee that SA_RESTART will cause
|
||||
// open(2) to be restarted for regular files. This is easy to reproduce on
|
||||
// fuse file systems (see http://golang.org/issue/11180).
|
||||
if e == syscall.EINTR {
|
||||
goto retry
|
||||
if runtime.GOOS == "darwin" && e == syscall.EINTR {
|
||||
continue
|
||||
}
|
||||
|
||||
return nil, &PathError{"open", name, e}
|
||||
|
Loading…
Reference in New Issue
Block a user