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) {
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,16 +115,16 @@ func convertErr(res int) error {
panic("unreachable")
}
func setReadDeadline(fd *netFD, t time.Time) error {
return setDeadlineImpl(fd, t, 'r')
func (fd *netFD) setDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'r'+'w')
}
func setWriteDeadline(fd *netFD, t time.Time) error {
return setDeadlineImpl(fd, t, 'w')
func (fd *netFD) setReadDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'r')
}
func setDeadline(fd *netFD, t time.Time) error {
return setDeadlineImpl(fd, t, 'r'+'w')
func (fd *netFD) setWriteDeadline(t time.Time) error {
return setDeadlineImpl(fd, t, 'w')
}
func setDeadlineImpl(fd *netFD, t time.Time, mode int) error {
......
......@@ -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 {
fd.pd.rdeadline.setTime(t)
func (fd *netFD) setDeadline(t time.Time) error {
fd.setReadDeadline(t)
fd.setWriteDeadline(t)
return nil
}
func setWriteDeadline(fd *netFD, t time.Time) error {
fd.pd.wdeadline.setTime(t)
func (fd *netFD) setReadDeadline(t time.Time) error {
fd.pd.rdeadline.setTime(t)
return nil
}
func setDeadline(fd *netFD, t time.Time) error {
setReadDeadline(fd, t)
setWriteDeadline(fd, t)
func (fd *netFD) setWriteDeadline(t time.Time) error {
fd.pd.wdeadline.setTime(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
......
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