Commit ac2f84d5 authored by Mikio Hara's avatar Mikio Hara

net: make unexposed methods start with lowercase letters

This change makes unexposed methods start with lowercase letters for
avoiding unnecessary confusion because the net package uses many
embedding structures and intrefaces for controlling exposure of APIs.

Note that this change leaves DNS-related methods as they are.

Change-Id: I253758d1659175c5d0af6b2efcd30ce83f46543d
Reviewed-on: https://go-review.googlesource.com/20784
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 50487b2c
......@@ -34,18 +34,18 @@ const (
mutexWMask = (1<<20 - 1) << 43
)
// Read operations must do RWLock(true)/RWUnlock(true).
// Write operations must do RWLock(false)/RWUnlock(false).
// Misc operations must do Incref/Decref. Misc operations include functions like
// setsockopt and setDeadline. They need to use Incref/Decref to ensure that
// they operate on the correct fd in presence of a concurrent Close call
// Read operations must do rwlock(true)/rwunlock(true).
// Write operations must do rwlock(false)/rwunlock(false).
// Misc operations must do incref/decref. Misc operations include functions like
// setsockopt and setDeadline. They need to use incref/decref to ensure that
// they operate on the correct fd in presence of a concurrent close call
// (otherwise fd can be closed under their feet).
// Close operation must do IncrefAndClose/Decref.
// Close operation must do increfAndClose/decref.
// RWLock/Incref return whether fd is open.
// RWUnlock/Decref return whether fd is closed and there are no remaining references.
// rwlock/incref return whether fd is open.
// rwunlock/decref return whether fd is closed and there are no remaining references.
func (mu *fdMutex) Incref() bool {
func (mu *fdMutex) incref() bool {
for {
old := atomic.LoadUint64(&mu.state)
if old&mutexClosed != 0 {
......@@ -61,7 +61,7 @@ func (mu *fdMutex) Incref() bool {
}
}
func (mu *fdMutex) IncrefAndClose() bool {
func (mu *fdMutex) increfAndClose() bool {
for {
old := atomic.LoadUint64(&mu.state)
if old&mutexClosed != 0 {
......@@ -90,7 +90,7 @@ func (mu *fdMutex) IncrefAndClose() bool {
}
}
func (mu *fdMutex) Decref() bool {
func (mu *fdMutex) decref() bool {
for {
old := atomic.LoadUint64(&mu.state)
if old&mutexRefMask == 0 {
......@@ -103,7 +103,7 @@ func (mu *fdMutex) Decref() bool {
}
}
func (mu *fdMutex) RWLock(read bool) bool {
func (mu *fdMutex) rwlock(read bool) bool {
var mutexBit, mutexWait, mutexMask uint64
var mutexSema *uint32
if read {
......@@ -146,7 +146,7 @@ func (mu *fdMutex) RWLock(read bool) bool {
}
}
func (mu *fdMutex) RWUnlock(read bool) bool {
func (mu *fdMutex) rwunlock(read bool) bool {
var mutexBit, mutexWait, mutexMask uint64
var mutexSema *uint32
if read {
......
......@@ -14,44 +14,44 @@ import (
func TestMutexLock(t *testing.T) {
var mu fdMutex
if !mu.Incref() {
if !mu.incref() {
t.Fatal("broken")
}
if mu.Decref() {
if mu.decref() {
t.Fatal("broken")
}
if !mu.RWLock(true) {
if !mu.rwlock(true) {
t.Fatal("broken")
}
if mu.RWUnlock(true) {
if mu.rwunlock(true) {
t.Fatal("broken")
}
if !mu.RWLock(false) {
if !mu.rwlock(false) {
t.Fatal("broken")
}
if mu.RWUnlock(false) {
if mu.rwunlock(false) {
t.Fatal("broken")
}
}
func TestMutexClose(t *testing.T) {
var mu fdMutex
if !mu.IncrefAndClose() {
if !mu.increfAndClose() {
t.Fatal("broken")
}
if mu.Incref() {
if mu.incref() {
t.Fatal("broken")
}
if mu.RWLock(true) {
if mu.rwlock(true) {
t.Fatal("broken")
}
if mu.RWLock(false) {
if mu.rwlock(false) {
t.Fatal("broken")
}
if mu.IncrefAndClose() {
if mu.increfAndClose() {
t.Fatal("broken")
}
}
......@@ -59,10 +59,10 @@ func TestMutexClose(t *testing.T) {
func TestMutexCloseUnblock(t *testing.T) {
c := make(chan bool)
var mu fdMutex
mu.RWLock(true)
mu.rwlock(true)
for i := 0; i < 4; i++ {
go func() {
if mu.RWLock(true) {
if mu.rwlock(true) {
t.Error("broken")
return
}
......@@ -76,7 +76,7 @@ func TestMutexCloseUnblock(t *testing.T) {
t.Fatal("broken")
default:
}
mu.IncrefAndClose() // Must unblock the readers.
mu.increfAndClose() // Must unblock the readers.
for i := 0; i < 4; i++ {
select {
case <-c:
......@@ -84,10 +84,10 @@ func TestMutexCloseUnblock(t *testing.T) {
t.Fatal("broken")
}
}
if mu.Decref() {
if mu.decref() {
t.Fatal("broken")
}
if !mu.RWUnlock(true) {
if !mu.rwunlock(true) {
t.Fatal("broken")
}
}
......@@ -103,21 +103,21 @@ func TestMutexPanic(t *testing.T) {
}
var mu fdMutex
ensurePanics(func() { mu.Decref() })
ensurePanics(func() { mu.RWUnlock(true) })
ensurePanics(func() { mu.RWUnlock(false) })
ensurePanics(func() { mu.decref() })
ensurePanics(func() { mu.rwunlock(true) })
ensurePanics(func() { mu.rwunlock(false) })
ensurePanics(func() { mu.Incref(); mu.Decref(); mu.Decref() })
ensurePanics(func() { mu.RWLock(true); mu.RWUnlock(true); mu.RWUnlock(true) })
ensurePanics(func() { mu.RWLock(false); mu.RWUnlock(false); mu.RWUnlock(false) })
ensurePanics(func() { mu.incref(); mu.decref(); mu.decref() })
ensurePanics(func() { mu.rwlock(true); mu.rwunlock(true); mu.rwunlock(true) })
ensurePanics(func() { mu.rwlock(false); mu.rwunlock(false); mu.rwunlock(false) })
// ensure that it's still not broken
mu.Incref()
mu.Decref()
mu.RWLock(true)
mu.RWUnlock(true)
mu.RWLock(false)
mu.RWUnlock(false)
mu.incref()
mu.decref()
mu.rwlock(true)
mu.rwunlock(true)
mu.rwlock(false)
mu.rwunlock(false)
}
func TestMutexStress(t *testing.T) {
......@@ -138,16 +138,16 @@ func TestMutexStress(t *testing.T) {
for i := 0; i < N; i++ {
switch r.Intn(3) {
case 0:
if !mu.Incref() {
if !mu.incref() {
t.Error("broken")
return
}
if mu.Decref() {
if mu.decref() {
t.Error("broken")
return
}
case 1:
if !mu.RWLock(true) {
if !mu.rwlock(true) {
t.Error("broken")
return
}
......@@ -158,12 +158,12 @@ func TestMutexStress(t *testing.T) {
}
readState[0]++
readState[1]++
if mu.RWUnlock(true) {
if mu.rwunlock(true) {
t.Error("broken")
return
}
case 2:
if !mu.RWLock(false) {
if !mu.rwlock(false) {
t.Error("broken")
return
}
......@@ -174,7 +174,7 @@ func TestMutexStress(t *testing.T) {
}
writeState[0]++
writeState[1]++
if mu.RWUnlock(false) {
if mu.rwunlock(false) {
t.Error("broken")
return
}
......@@ -186,10 +186,10 @@ func TestMutexStress(t *testing.T) {
for p := 0; p < P; p++ {
<-done
}
if !mu.IncrefAndClose() {
if !mu.increfAndClose() {
t.Fatal("broken")
}
if !mu.Decref() {
if !mu.decref() {
t.Fatal("broken")
}
}
......@@ -77,7 +77,7 @@ func (fd *netFD) destroy() {
// Add a reference to this fd.
// Returns an error if the fd cannot be used.
func (fd *netFD) incref() error {
if !fd.fdmu.Incref() {
if !fd.fdmu.incref() {
return errClosing
}
return nil
......@@ -86,7 +86,7 @@ func (fd *netFD) incref() error {
// Remove a reference to this FD and close if we've been asked to do so
// (and there are no references left).
func (fd *netFD) decref() {
if fd.fdmu.Decref() {
if fd.fdmu.decref() {
fd.destroy()
}
}
......@@ -94,7 +94,7 @@ func (fd *netFD) decref() {
// Add a reference to this fd and lock for reading.
// Returns an error if the fd cannot be used.
func (fd *netFD) readLock() error {
if !fd.fdmu.RWLock(true) {
if !fd.fdmu.rwlock(true) {
return errClosing
}
return nil
......@@ -102,7 +102,7 @@ func (fd *netFD) readLock() error {
// Unlock for reading and remove a reference to this FD.
func (fd *netFD) readUnlock() {
if fd.fdmu.RWUnlock(true) {
if fd.fdmu.rwunlock(true) {
fd.destroy()
}
}
......@@ -110,7 +110,7 @@ func (fd *netFD) readUnlock() {
// Add a reference to this fd and lock for writing.
// Returns an error if the fd cannot be used.
func (fd *netFD) writeLock() error {
if !fd.fdmu.RWLock(false) {
if !fd.fdmu.rwlock(false) {
return errClosing
}
return nil
......@@ -118,7 +118,7 @@ func (fd *netFD) writeLock() error {
// Unlock for writing and remove a reference to this FD.
func (fd *netFD) writeUnlock() {
if fd.fdmu.RWUnlock(false) {
if fd.fdmu.rwunlock(false) {
fd.destroy()
}
}
......@@ -165,7 +165,7 @@ func (fd *netFD) closeWrite() error {
}
func (fd *netFD) Close() error {
if !fd.fdmu.IncrefAndClose() {
if !fd.fdmu.increfAndClose() {
return errClosing
}
if !fd.ok() {
......
......@@ -14,44 +14,44 @@ type pollDesc struct {
closing bool
}
func (pd *pollDesc) Init(fd *netFD) error { pd.fd = fd; return nil }
func (pd *pollDesc) init(fd *netFD) error { pd.fd = fd; return nil }
func (pd *pollDesc) Close() {}
func (pd *pollDesc) close() {}
func (pd *pollDesc) Evict() {
func (pd *pollDesc) evict() {
pd.closing = true
if pd.fd != nil {
syscall.StopIO(pd.fd.sysfd)
}
}
func (pd *pollDesc) Prepare(mode int) error {
func (pd *pollDesc) prepare(mode int) error {
if pd.closing {
return errClosing
}
return nil
}
func (pd *pollDesc) PrepareRead() error { return pd.Prepare('r') }
func (pd *pollDesc) prepareRead() error { return pd.prepare('r') }
func (pd *pollDesc) PrepareWrite() error { return pd.Prepare('w') }
func (pd *pollDesc) prepareWrite() error { return pd.prepare('w') }
func (pd *pollDesc) Wait(mode int) error {
func (pd *pollDesc) wait(mode int) error {
if pd.closing {
return errClosing
}
return errTimeout
}
func (pd *pollDesc) WaitRead() error { return pd.Wait('r') }
func (pd *pollDesc) waitRead() error { return pd.wait('r') }
func (pd *pollDesc) WaitWrite() error { return pd.Wait('w') }
func (pd *pollDesc) waitWrite() error { return pd.wait('w') }
func (pd *pollDesc) WaitCanceled(mode int) {}
func (pd *pollDesc) waitCanceled(mode int) {}
func (pd *pollDesc) WaitCanceledRead() {}
func (pd *pollDesc) waitCanceledRead() {}
func (pd *pollDesc) WaitCanceledWrite() {}
func (pd *pollDesc) waitCanceledWrite() {}
func (fd *netFD) setDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'r'+'w')
......
......@@ -30,7 +30,7 @@ type pollDesc struct {
var serverInit sync.Once
func (pd *pollDesc) Init(fd *netFD) error {
func (pd *pollDesc) init(fd *netFD) error {
serverInit.Do(runtime_pollServerInit)
ctx, errno := runtime_pollOpen(uintptr(fd.sysfd))
if errno != 0 {
......@@ -40,7 +40,7 @@ func (pd *pollDesc) Init(fd *netFD) error {
return nil
}
func (pd *pollDesc) Close() {
func (pd *pollDesc) close() {
if pd.runtimeCtx == 0 {
return
}
......@@ -49,49 +49,49 @@ func (pd *pollDesc) Close() {
}
// Evict evicts fd from the pending list, unblocking any I/O running on fd.
func (pd *pollDesc) Evict() {
func (pd *pollDesc) evict() {
if pd.runtimeCtx == 0 {
return
}
runtime_pollUnblock(pd.runtimeCtx)
}
func (pd *pollDesc) Prepare(mode int) error {
func (pd *pollDesc) prepare(mode int) error {
res := runtime_pollReset(pd.runtimeCtx, mode)
return convertErr(res)
}
func (pd *pollDesc) PrepareRead() error {
return pd.Prepare('r')
func (pd *pollDesc) prepareRead() error {
return pd.prepare('r')
}
func (pd *pollDesc) PrepareWrite() error {
return pd.Prepare('w')
func (pd *pollDesc) prepareWrite() error {
return pd.prepare('w')
}
func (pd *pollDesc) Wait(mode int) error {
func (pd *pollDesc) wait(mode int) error {
res := runtime_pollWait(pd.runtimeCtx, mode)
return convertErr(res)
}
func (pd *pollDesc) WaitRead() error {
return pd.Wait('r')
func (pd *pollDesc) waitRead() error {
return pd.wait('r')
}
func (pd *pollDesc) WaitWrite() error {
return pd.Wait('w')
func (pd *pollDesc) waitWrite() error {
return pd.wait('w')
}
func (pd *pollDesc) WaitCanceled(mode int) {
func (pd *pollDesc) waitCanceled(mode int) {
runtime_pollWaitCanceled(pd.runtimeCtx, mode)
}
func (pd *pollDesc) WaitCanceledRead() {
pd.WaitCanceled('r')
func (pd *pollDesc) waitCanceledRead() {
pd.waitCanceled('r')
}
func (pd *pollDesc) WaitCanceledWrite() {
pd.WaitCanceled('w')
func (pd *pollDesc) waitCanceledWrite() {
pd.waitCanceled('w')
}
func convertErr(res int) error {
......
......@@ -45,7 +45,7 @@ func newFD(sysfd, family, sotype int, net string) (*netFD, error) {
}
func (fd *netFD) init() error {
if err := fd.pd.Init(fd); err != nil {
if err := fd.pd.init(fd); err != nil {
return err
}
return nil
......@@ -124,7 +124,7 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr, deadline time.Time, cancel <-c
// SO_ERROR socket option to see if the connection
// succeeded or failed. See issue 7474 for further
// details.
if err := fd.pd.WaitWrite(); err != nil {
if err := fd.pd.waitWrite(); err != nil {
select {
case <-cancel:
return errCanceled
......@@ -158,7 +158,7 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr, deadline time.Time, cancel <-c
func (fd *netFD) destroy() {
// Poller may want to unregister fd in readiness notification mechanism,
// so this must be executed before closeFunc.
fd.pd.Close()
fd.pd.close()
closeFunc(fd.sysfd)
fd.sysfd = -1
runtime.SetFinalizer(fd, nil)
......@@ -167,7 +167,7 @@ func (fd *netFD) destroy() {
// Add a reference to this fd.
// Returns an error if the fd cannot be used.
func (fd *netFD) incref() error {
if !fd.fdmu.Incref() {
if !fd.fdmu.incref() {
return errClosing
}
return nil
......@@ -176,7 +176,7 @@ func (fd *netFD) incref() error {
// Remove a reference to this FD and close if we've been asked to do so
// (and there are no references left).
func (fd *netFD) decref() {
if fd.fdmu.Decref() {
if fd.fdmu.decref() {
fd.destroy()
}
}
......@@ -184,7 +184,7 @@ func (fd *netFD) decref() {
// Add a reference to this fd and lock for reading.
// Returns an error if the fd cannot be used.
func (fd *netFD) readLock() error {
if !fd.fdmu.RWLock(true) {
if !fd.fdmu.rwlock(true) {
return errClosing
}
return nil
......@@ -192,7 +192,7 @@ func (fd *netFD) readLock() error {
// Unlock for reading and remove a reference to this FD.
func (fd *netFD) readUnlock() {
if fd.fdmu.RWUnlock(true) {
if fd.fdmu.rwunlock(true) {
fd.destroy()
}
}
......@@ -200,7 +200,7 @@ func (fd *netFD) readUnlock() {
// Add a reference to this fd and lock for writing.
// Returns an error if the fd cannot be used.
func (fd *netFD) writeLock() error {
if !fd.fdmu.RWLock(false) {
if !fd.fdmu.rwlock(false) {
return errClosing
}
return nil
......@@ -208,13 +208,13 @@ func (fd *netFD) writeLock() error {
// Unlock for writing and remove a reference to this FD.
func (fd *netFD) writeUnlock() {
if fd.fdmu.RWUnlock(false) {
if fd.fdmu.rwunlock(false) {
fd.destroy()
}
}
func (fd *netFD) Close() error {
if !fd.fdmu.IncrefAndClose() {
if !fd.fdmu.increfAndClose() {
return errClosing
}
// Unblock any I/O. Once it all unblocks and returns,
......@@ -222,7 +222,7 @@ func (fd *netFD) Close() error {
// the final decref will close fd.sysfd. This should happen
// fairly quickly, since all the I/O is non-blocking, and any
// attempts to block in the pollDesc will return errClosing.
fd.pd.Evict()
fd.pd.evict()
fd.decref()
return nil
}
......@@ -248,7 +248,7 @@ func (fd *netFD) Read(p []byte) (n int, err error) {
return 0, err
}
defer fd.readUnlock()
if err := fd.pd.PrepareRead(); err != nil {
if err := fd.pd.prepareRead(); err != nil {
return 0, err
}
for {
......@@ -256,7 +256,7 @@ func (fd *netFD) Read(p []byte) (n int, err error) {
if err != nil {
n = 0
if err == syscall.EAGAIN {
if err = fd.pd.WaitRead(); err == nil {
if err = fd.pd.waitRead(); err == nil {
continue
}
}
......@@ -275,7 +275,7 @@ func (fd *netFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error) {
return 0, nil, err
}
defer fd.readUnlock()
if err := fd.pd.PrepareRead(); err != nil {
if err := fd.pd.prepareRead(); err != nil {
return 0, nil, err
}
for {
......@@ -283,7 +283,7 @@ func (fd *netFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error) {
if err != nil {
n = 0
if err == syscall.EAGAIN {
if err = fd.pd.WaitRead(); err == nil {
if err = fd.pd.waitRead(); err == nil {
continue
}
}
......@@ -302,7 +302,7 @@ func (fd *netFD) readMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S
return 0, 0, 0, nil, err
}
defer fd.readUnlock()
if err := fd.pd.PrepareRead(); err != nil {
if err := fd.pd.prepareRead(); err != nil {
return 0, 0, 0, nil, err
}
for {
......@@ -310,7 +310,7 @@ func (fd *netFD) readMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S
if err != nil {
// TODO(dfc) should n and oobn be set to 0
if err == syscall.EAGAIN {
if err = fd.pd.WaitRead(); err == nil {
if err = fd.pd.waitRead(); err == nil {
continue
}
}
......@@ -329,7 +329,7 @@ func (fd *netFD) Write(p []byte) (nn int, err error) {
return 0, err
}
defer fd.writeUnlock()
if err := fd.pd.PrepareWrite(); err != nil {
if err := fd.pd.prepareWrite(); err != nil {
return 0, err
}
for {
......@@ -342,7 +342,7 @@ func (fd *netFD) Write(p []byte) (nn int, err error) {
break
}
if err == syscall.EAGAIN {
if err = fd.pd.WaitWrite(); err == nil {
if err = fd.pd.waitWrite(); err == nil {
continue
}
}
......@@ -365,13 +365,13 @@ func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) {
return 0, err
}
defer fd.writeUnlock()
if err := fd.pd.PrepareWrite(); err != nil {
if err := fd.pd.prepareWrite(); err != nil {
return 0, err
}
for {
err = syscall.Sendto(fd.sysfd, p, 0, sa)
if err == syscall.EAGAIN {
if err = fd.pd.WaitWrite(); err == nil {
if err = fd.pd.waitWrite(); err == nil {
continue
}
}
......@@ -391,13 +391,13 @@ func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oob
return 0, 0, err
}
defer fd.writeUnlock()
if err := fd.pd.PrepareWrite(); err != nil {
if err := fd.pd.prepareWrite(); err != nil {
return 0, 0, err
}
for {
n, err = syscall.SendmsgN(fd.sysfd, p, oob, sa, 0)
if err == syscall.EAGAIN {
if err = fd.pd.WaitWrite(); err == nil {
if err = fd.pd.waitWrite(); err == nil {
continue
}
}
......@@ -420,7 +420,7 @@ func (fd *netFD) accept() (netfd *netFD, err error) {
var s int
var rsa syscall.Sockaddr
if err = fd.pd.PrepareRead(); err != nil {
if err = fd.pd.prepareRead(); err != nil {
return nil, err
}
for {
......@@ -432,7 +432,7 @@ func (fd *netFD) accept() (netfd *netFD, err error) {
}
switch nerr.Err {
case syscall.EAGAIN:
if err = fd.pd.WaitRead(); err == nil {
if err = fd.pd.waitRead(); err == nil {
continue
}
case syscall.ECONNABORTED:
......
......@@ -152,7 +152,7 @@ func (s *ioSrv) ProcessRemoteIO() {
func (s *ioSrv) ExecIO(o *operation, name string, submit func(o *operation) error) (int, error) {
fd := o.fd
// Notify runtime netpoll about starting IO.
err := fd.pd.Prepare(int(o.mode))
err := fd.pd.prepare(int(o.mode))
if err != nil {
return 0, err
}
......@@ -180,7 +180,7 @@ func (s *ioSrv) ExecIO(o *operation, name string, submit func(o *operation) erro
return 0, err
}
// Wait for our request to complete.
err = fd.pd.Wait(int(o.mode))
err = fd.pd.wait(int(o.mode))
if err == nil {
// All is good. Extract our IO results and return.
if o.errno != 0 {
......@@ -210,7 +210,7 @@ func (s *ioSrv) ExecIO(o *operation, name string, submit func(o *operation) erro
<-o.errc
}
// Wait for cancelation to complete.
fd.pd.WaitCanceled(int(o.mode))
fd.pd.waitCanceled(int(o.mode))
if o.errno != 0 {
err = syscall.Errno(o.errno)
if err == syscall.ERROR_OPERATION_ABORTED { // IO Canceled
......@@ -273,7 +273,7 @@ func newFD(sysfd syscall.Handle, family, sotype int, net string) (*netFD, error)
}
func (fd *netFD) init() error {
if err := fd.pd.Init(fd); err != nil {
if err := fd.pd.init(fd); err != nil {
return err
}
if hasLoadSetFileCompletionNotificationModes {
......@@ -388,7 +388,7 @@ func (fd *netFD) destroy() {
}
// Poller may want to unregister fd in readiness notification mechanism,
// so this must be executed before closeFunc.
fd.pd.Close()
fd.pd.close()
closeFunc(fd.sysfd)
fd.sysfd = syscall.InvalidHandle
// no need for a finalizer anymore
......@@ -398,7 +398,7 @@ func (fd *netFD) destroy() {
// Add a reference to this fd.
// Returns an error if the fd cannot be used.
func (fd *netFD) incref() error {
if !fd.fdmu.Incref() {
if !fd.fdmu.incref() {
return errClosing
}
return nil
......@@ -407,7 +407,7 @@ func (fd *netFD) incref() error {
// Remove a reference to this FD and close if we've been asked to do so
// (and there are no references left).
func (fd *netFD) decref() {
if fd.fdmu.Decref() {
if fd.fdmu.decref() {
fd.destroy()
}
}
......@@ -415,7 +415,7 @@ func (fd *netFD) decref() {
// Add a reference to this fd and lock for reading.
// Returns an error if the fd cannot be used.
func (fd *netFD) readLock() error {
if !fd.fdmu.RWLock(true) {
if !fd.fdmu.rwlock(true) {
return errClosing
}
return nil
......@@ -423,7 +423,7 @@ func (fd *netFD) readLock() error {
// Unlock for reading and remove a reference to this FD.
func (fd *netFD) readUnlock() {
if fd.fdmu.RWUnlock(true) {
if fd.fdmu.rwunlock(true) {
fd.destroy()
}
}
......@@ -431,7 +431,7 @@ func (fd *netFD) readUnlock() {
// Add a reference to this fd and lock for writing.
// Returns an error if the fd cannot be used.
func (fd *netFD) writeLock() error {
if !fd.fdmu.RWLock(false) {
if !fd.fdmu.rwlock(false) {
return errClosing
}
return nil
......@@ -439,17 +439,17 @@ func (fd *netFD) writeLock() error {
// Unlock for writing and remove a reference to this FD.
func (fd *netFD) writeUnlock() {
if fd.fdmu.RWUnlock(false) {
if fd.fdmu.rwunlock(false) {
fd.destroy()
}
}
func (fd *netFD) Close() error {
if !fd.fdmu.IncrefAndClose() {
if !fd.fdmu.increfAndClose() {
return errClosing
}
// unblock pending reader and writer
fd.pd.Evict()
fd.pd.evict()
fd.decref()
return nil
}
......
......@@ -81,7 +81,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
break
}
if err1 == syscall.EAGAIN {
if err1 = c.pd.WaitWrite(); err1 == nil {
if err1 = c.pd.waitWrite(); err1 == nil {
continue
}
}
......
......@@ -81,7 +81,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
break
}
if err1 == syscall.EAGAIN {
if err1 = c.pd.WaitWrite(); err1 == nil {
if err1 = c.pd.waitWrite(); err1 == nil {
continue
}
}
......
......@@ -57,7 +57,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
break
}
if err1 == syscall.EAGAIN {
if err1 = c.pd.WaitWrite(); err1 == nil {
if err1 = c.pd.waitWrite(); err1 == nil {
continue
}
}
......
......@@ -87,7 +87,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
break
}
if err1 == syscall.EAGAIN {
if err1 = c.pd.WaitWrite(); err1 == nil {
if err1 = c.pd.waitWrite(); err1 == nil {
continue
}
}
......
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