Commit 39a7017c authored by Mikio Hara's avatar Mikio Hara

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
parent 5a20b4a6
...@@ -108,15 +108,15 @@ func (fd *netFD) file(f *os.File, s string) (*os.File, error) { ...@@ -108,15 +108,15 @@ func (fd *netFD) file(f *os.File, s string) (*os.File, error) {
return os.NewFile(uintptr(dfd), s), nil 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 return syscall.EPLAN9
} }
func setReadDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setReadDeadline(t time.Time) error {
return syscall.EPLAN9 return syscall.EPLAN9
} }
func setWriteDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setWriteDeadline(t time.Time) error {
return syscall.EPLAN9 return syscall.EPLAN9
} }
......
...@@ -115,16 +115,16 @@ func convertErr(res int) error { ...@@ -115,16 +115,16 @@ func convertErr(res int) error {
panic("unreachable") panic("unreachable")
} }
func setReadDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'r') return setDeadlineImpl(fd, t, 'r'+'w')
} }
func setWriteDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setReadDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'w') return setDeadlineImpl(fd, t, 'r')
} }
func setDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setWriteDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'r'+'w') return setDeadlineImpl(fd, t, 'w')
} }
func setDeadlineImpl(fd *netFD, t time.Time, mode int) error { func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
......
...@@ -353,18 +353,18 @@ func (pd *pollDesc) Init(fd *netFD) error { ...@@ -353,18 +353,18 @@ func (pd *pollDesc) Init(fd *netFD) error {
// TODO(dfc) these unused error returns could be removed // 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.pd.rdeadline.setTime(t) fd.setReadDeadline(t)
fd.setWriteDeadline(t)
return nil return nil
} }
func setWriteDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setReadDeadline(t time.Time) error {
fd.pd.wdeadline.setTime(t) fd.pd.rdeadline.setTime(t)
return nil return nil
} }
func setDeadline(fd *netFD, t time.Time) error { func (fd *netFD) setWriteDeadline(t time.Time) error {
setReadDeadline(fd, t) fd.pd.wdeadline.setTime(t)
setWriteDeadline(fd, t)
return nil return nil
} }
...@@ -160,7 +160,7 @@ func (c *conn) SetDeadline(t time.Time) error { ...@@ -160,7 +160,7 @@ func (c *conn) SetDeadline(t time.Time) error {
if !c.ok() { if !c.ok() {
return syscall.EINVAL return syscall.EINVAL
} }
return setDeadline(c.fd, t) return c.fd.setDeadline(t)
} }
// SetReadDeadline implements the Conn SetReadDeadline method. // SetReadDeadline implements the Conn SetReadDeadline method.
...@@ -168,7 +168,7 @@ func (c *conn) SetReadDeadline(t time.Time) error { ...@@ -168,7 +168,7 @@ func (c *conn) SetReadDeadline(t time.Time) error {
if !c.ok() { if !c.ok() {
return syscall.EINVAL return syscall.EINVAL
} }
return setReadDeadline(c.fd, t) return c.fd.setReadDeadline(t)
} }
// SetWriteDeadline implements the Conn SetWriteDeadline method. // SetWriteDeadline implements the Conn SetWriteDeadline method.
...@@ -176,7 +176,7 @@ func (c *conn) SetWriteDeadline(t time.Time) error { ...@@ -176,7 +176,7 @@ func (c *conn) SetWriteDeadline(t time.Time) error {
if !c.ok() { if !c.ok() {
return syscall.EINVAL return syscall.EINVAL
} }
return setWriteDeadline(c.fd, t) return c.fd.setWriteDeadline(t)
} }
// SetReadBuffer sets the size of the operating system's // 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 ...@@ -113,14 +113,14 @@ func (fd *netFD) dial(laddr, raddr sockaddr, deadline time.Time, toAddr func(sys
return err return err
} else if rsa != nil { } else if rsa != nil {
if !deadline.IsZero() { if !deadline.IsZero() {
setWriteDeadline(fd, deadline) fd.setWriteDeadline(deadline)
} }
if err := fd.connect(lsa, rsa); err != nil { if err := fd.connect(lsa, rsa); err != nil {
return err return err
} }
fd.isConnected = true fd.isConnected = true
if !deadline.IsZero() { if !deadline.IsZero() {
setWriteDeadline(fd, noDeadline) fd.setWriteDeadline(noDeadline)
} }
} }
} }
......
...@@ -158,7 +158,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error { ...@@ -158,7 +158,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
if l == nil || l.fd == nil || l.fd.ctl == nil { if l == nil || l.fd == nil || l.fd.ctl == nil {
return syscall.EINVAL 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 // File returns a copy of the underlying os.File, set to blocking
......
...@@ -272,7 +272,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error { ...@@ -272,7 +272,7 @@ func (l *TCPListener) SetDeadline(t time.Time) error {
if l == nil || l.fd == nil { if l == nil || l.fd == nil {
return syscall.EINVAL 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 // 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) { ...@@ -347,7 +347,7 @@ func (l *UnixListener) SetDeadline(t time.Time) (err error) {
if l == nil || l.fd == nil { if l == nil || l.fd == nil {
return syscall.EINVAL 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 // File returns a copy of the underlying os.File, set to blocking
......
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