mirror of
https://github.com/golang/go
synced 2024-11-12 02:50:25 -07:00
net: make deadline helpers join to netFD as its methods
Just for readability reasons; to prevent overlooking deadline stuff across over platforms. R=golang-dev, dvyukov CC=golang-dev https://golang.org/cl/8656044
This commit is contained in:
parent
5a20b4a6a9
commit
39a7017c26
@ -108,15 +108,15 @@ func (fd *netFD) file(f *os.File, s string) (*os.File, error) {
|
||||
return os.NewFile(uintptr(dfd), s), nil
|
||||
}
|
||||
|
||||
func setDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setDeadline(t time.Time) error {
|
||||
return syscall.EPLAN9
|
||||
}
|
||||
|
||||
func setReadDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setReadDeadline(t time.Time) error {
|
||||
return syscall.EPLAN9
|
||||
}
|
||||
|
||||
func setWriteDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setWriteDeadline(t time.Time) error {
|
||||
return syscall.EPLAN9
|
||||
}
|
||||
|
||||
|
@ -115,18 +115,18 @@ func convertErr(res int) error {
|
||||
panic("unreachable")
|
||||
}
|
||||
|
||||
func setReadDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'r'+'w')
|
||||
}
|
||||
|
||||
func (fd *netFD) setReadDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'r')
|
||||
}
|
||||
|
||||
func setWriteDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setWriteDeadline(t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'w')
|
||||
}
|
||||
|
||||
func setDeadline(fd *netFD, t time.Time) error {
|
||||
return setDeadlineImpl(fd, t, 'r'+'w')
|
||||
}
|
||||
|
||||
func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
|
||||
d := t.UnixNano()
|
||||
if t.IsZero() {
|
||||
|
@ -353,18 +353,18 @@ func (pd *pollDesc) Init(fd *netFD) error {
|
||||
|
||||
// TODO(dfc) these unused error returns could be removed
|
||||
|
||||
func setReadDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setDeadline(t time.Time) error {
|
||||
fd.setReadDeadline(t)
|
||||
fd.setWriteDeadline(t)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fd *netFD) setReadDeadline(t time.Time) error {
|
||||
fd.pd.rdeadline.setTime(t)
|
||||
return nil
|
||||
}
|
||||
|
||||
func setWriteDeadline(fd *netFD, t time.Time) error {
|
||||
func (fd *netFD) setWriteDeadline(t time.Time) error {
|
||||
fd.pd.wdeadline.setTime(t)
|
||||
return nil
|
||||
}
|
||||
|
||||
func setDeadline(fd *netFD, t time.Time) error {
|
||||
setReadDeadline(fd, t)
|
||||
setWriteDeadline(fd, t)
|
||||
return nil
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func (c *conn) SetDeadline(t time.Time) error {
|
||||
if !c.ok() {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setDeadline(c.fd, t)
|
||||
return c.fd.setDeadline(t)
|
||||
}
|
||||
|
||||
// SetReadDeadline implements the Conn SetReadDeadline method.
|
||||
@ -168,7 +168,7 @@ func (c *conn) SetReadDeadline(t time.Time) error {
|
||||
if !c.ok() {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setReadDeadline(c.fd, t)
|
||||
return c.fd.setReadDeadline(t)
|
||||
}
|
||||
|
||||
// SetWriteDeadline implements the Conn SetWriteDeadline method.
|
||||
@ -176,7 +176,7 @@ func (c *conn) SetWriteDeadline(t time.Time) error {
|
||||
if !c.ok() {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setWriteDeadline(c.fd, t)
|
||||
return c.fd.setWriteDeadline(t)
|
||||
}
|
||||
|
||||
// SetReadBuffer sets the size of the operating system's
|
||||
|
@ -113,14 +113,14 @@ func (fd *netFD) dial(laddr, raddr sockaddr, deadline time.Time, toAddr func(sys
|
||||
return err
|
||||
} else if rsa != nil {
|
||||
if !deadline.IsZero() {
|
||||
setWriteDeadline(fd, deadline)
|
||||
fd.setWriteDeadline(deadline)
|
||||
}
|
||||
if err := fd.connect(lsa, rsa); err != nil {
|
||||
return err
|
||||
}
|
||||
fd.isConnected = true
|
||||
if !deadline.IsZero() {
|
||||
setWriteDeadline(fd, noDeadline)
|
||||
fd.setWriteDeadline(noDeadline)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
|
||||
if l == nil || l.fd == nil || l.fd.ctl == nil {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setDeadline(l.fd, t)
|
||||
return l.fd.setDeadline(t)
|
||||
}
|
||||
|
||||
// File returns a copy of the underlying os.File, set to blocking
|
||||
|
@ -272,7 +272,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
|
||||
if l == nil || l.fd == nil {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setDeadline(l.fd, t)
|
||||
return l.fd.setDeadline(t)
|
||||
}
|
||||
|
||||
// File returns a copy of the underlying os.File, set to blocking
|
||||
|
@ -347,7 +347,7 @@ func (l *UnixListener) SetDeadline(t time.Time) (err error) {
|
||||
if l == nil || l.fd == nil {
|
||||
return syscall.EINVAL
|
||||
}
|
||||
return setDeadline(l.fd, t)
|
||||
return l.fd.setDeadline(t)
|
||||
}
|
||||
|
||||
// File returns a copy of the underlying os.File, set to blocking
|
||||
|
Loading…
Reference in New Issue
Block a user