Commit e7e27398 authored by Aaron Jacobs's avatar Aaron Jacobs Committed by Rob Pike

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/14673Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 001a75a7
......@@ -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}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment