diff options
author | Russ Cox <rsc@golang.org> | 2009-02-15 19:35:52 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-02-15 19:35:52 -0800 |
commit | 6c76acf88cb2c97bf60c34caa01e868f61bad436 (patch) | |
tree | 9600ec63eb31a171bc1f911505eae0806b9d33d5 /src/lib/net/fd.go | |
parent | 491b1c363470e285bb91b69c32e6a023dcc66643 (diff) | |
download | golang-6c76acf88cb2c97bf60c34caa01e868f61bad436.tar.gz |
add os.ForkExec, os.Exec, os.Wait, exec.OpenCmd.
as thread-safe as possible, given the surrounding system.
add stub RWLock implementation.
R=r
DELTA=852 (834 added, 6 deleted, 12 changed)
OCL=25046
CL=25053
Diffstat (limited to 'src/lib/net/fd.go')
-rw-r--r-- | src/lib/net/fd.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/net/fd.go b/src/lib/net/fd.go index 1ec0d8af9..0c7770c77 100644 --- a/src/lib/net/fd.go +++ b/src/lib/net/fd.go @@ -280,17 +280,26 @@ func (fd *netFD) Accept(sa *syscall.Sockaddr) (nfd *netFD, err *os.Error) { return nil, os.EINVAL } + // See ../syscall/exec.go for description of ForkLock. + // It is okay to hold the lock across syscall.Accept + // because we have put fd.fd into non-blocking mode. + syscall.ForkLock.RLock(); var s, e int64; for { s, e = syscall.Accept(fd.fd, sa); if e != syscall.EAGAIN { break; } + syscall.ForkLock.RUnlock(); pollserver.WaitRead(fd); + syscall.ForkLock.RLock(); } if e != 0 { + syscall.ForkLock.RUnlock(); return nil, os.ErrnoToError(e) } + syscall.CloseOnExec(s); + syscall.ForkLock.RUnlock(); raddr, err1 := sockaddrToHostPort(sa); if err1 != nil { |