]> Cypherpunks repositories - gostls13.git/commitdiff
os: don't hold ForkLock across opens on Plan 9
authorAkshat Kumar <seed@mail.nanosouffle.net>
Wed, 30 Jan 2013 17:41:16 +0000 (09:41 -0800)
committerRuss Cox <rsc@golang.org>
Wed, 30 Jan 2013 17:41:16 +0000 (09:41 -0800)
If os.OpenFile holds ForkLock on files that block opens,
then threads that simultaneously try to do fork-exec will
get hung up (until the open succeeds). Blocked opens are
common enough on Plan 9 that protecting against fd leaks
into fork-execs means not being able to do fork-execs
properly in the general case. Thus, we forgo taking the
lock.

R=rsc, ality
CC=golang-dev
https://golang.org/cl/7235066

src/pkg/os/file_plan9.go

index fb2f2347d7d071fb7c99a14198d3b59b8221b5a9..fabe5b979ca30ef1c1f8a1f6b72dd1c996210812 100644 (file)
@@ -104,7 +104,6 @@ func OpenFile(name string, flag int, perm FileMode) (file *File, err error) {
                append = true
        }
 
-       syscall.ForkLock.RLock()
        if (create && trunc) || excl {
                fd, e = syscall.Create(name, flag, syscallMode(perm))
        } else {
@@ -117,7 +116,6 @@ func OpenFile(name string, flag int, perm FileMode) (file *File, err error) {
                        }
                }
        }
-       syscall.ForkLock.RUnlock()
 
        if e != nil {
                return nil, &PathError{"open", name, e}