mirror of
https://github.com/golang/go
synced 2024-11-25 03:47:57 -07:00
net: Return error from CloseRead and CloseWrite.
R=bradfitz, rsc, iant CC=golang-dev https://golang.org/cl/5167043
This commit is contained in:
parent
51057bda3f
commit
791b2a498e
@ -358,20 +358,23 @@ func (fd *netFD) Close() os.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseRead() os.Error {
|
||||
func (fd *netFD) shutdown(how int) os.Error {
|
||||
if fd == nil || fd.sysfile == nil {
|
||||
return os.EINVAL
|
||||
}
|
||||
syscall.Shutdown(fd.sysfd, syscall.SHUT_RD)
|
||||
errno := syscall.Shutdown(fd.sysfd, how)
|
||||
if errno != 0 {
|
||||
return &OpError{"shutdown", fd.net, fd.laddr, os.Errno(errno)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseRead() os.Error {
|
||||
return fd.shutdown(syscall.SHUT_RD)
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseWrite() os.Error {
|
||||
if fd == nil || fd.sysfile == nil {
|
||||
return os.EINVAL
|
||||
}
|
||||
syscall.Shutdown(fd.sysfd, syscall.SHUT_WR)
|
||||
return nil
|
||||
return fd.shutdown(syscall.SHUT_WR)
|
||||
}
|
||||
|
||||
func (fd *netFD) Read(p []byte) (n int, err os.Error) {
|
||||
|
@ -312,20 +312,23 @@ func (fd *netFD) Close() os.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseRead() os.Error {
|
||||
func (fd *netFD) shutdown(how int) os.Error {
|
||||
if fd == nil || fd.sysfd == syscall.InvalidHandle {
|
||||
return os.EINVAL
|
||||
}
|
||||
syscall.Shutdown(fd.sysfd, syscall.SHUT_RD)
|
||||
errno := syscall.Shutdown(fd.sysfd, how)
|
||||
if errno != 0 {
|
||||
return &OpError{"shutdown", fd.net, fd.laddr, os.Errno(errno)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseRead() os.Error {
|
||||
return fd.shutdown(syscall.SHUT_RD)
|
||||
}
|
||||
|
||||
func (fd *netFD) CloseWrite() os.Error {
|
||||
if fd == nil || fd.sysfd == syscall.InvalidHandle {
|
||||
return os.EINVAL
|
||||
}
|
||||
syscall.Shutdown(fd.sysfd, syscall.SHUT_WR)
|
||||
return nil
|
||||
return fd.shutdown(syscall.SHUT_WR)
|
||||
}
|
||||
|
||||
// Read from network.
|
||||
|
Loading…
Reference in New Issue
Block a user