aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/fd_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/fd_unix.go')
-rw-r--r--libgo/go/net/fd_unix.go94
1 files changed, 8 insertions, 86 deletions
diff --git a/libgo/go/net/fd_unix.go b/libgo/go/net/fd_unix.go
index 117f5a9..ad79c06 100644
--- a/libgo/go/net/fd_unix.go
+++ b/libgo/go/net/fd_unix.go
@@ -12,21 +12,16 @@ import (
"os"
"runtime"
"syscall"
- "time"
)
-// Network file descriptor.
-type netFD struct {
- pfd poll.FD
-
- // immutable until Close
- family int
- sotype int
- isConnected bool // handshake completed or use of association with peer
- net string
- laddr Addr
- raddr Addr
-}
+const (
+ readSyscallName = "read"
+ readFromSyscallName = "recvfrom"
+ readMsgSyscallName = "recvmsg"
+ writeSyscallName = "write"
+ writeToSyscallName = "sendto"
+ writeMsgSyscallName = "sendmsg"
+)
func newFD(sysfd, family, sotype int, net string) (*netFD, error) {
ret := &netFD{
@@ -46,12 +41,6 @@ func (fd *netFD) init() error {
return fd.pfd.Init(fd.net, true)
}
-func (fd *netFD) setAddr(laddr, raddr Addr) {
- fd.laddr = laddr
- fd.raddr = raddr
- runtime.SetFinalizer(fd, (*netFD).Close)
-}
-
func (fd *netFD) name() string {
var ls, rs string
if fd.laddr != nil {
@@ -179,61 +168,6 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (rsa sysc
}
}
-func (fd *netFD) Close() error {
- runtime.SetFinalizer(fd, nil)
- return fd.pfd.Close()
-}
-
-func (fd *netFD) shutdown(how int) error {
- err := fd.pfd.Shutdown(how)
- runtime.KeepAlive(fd)
- return wrapSyscallError("shutdown", err)
-}
-
-func (fd *netFD) closeRead() error {
- return fd.shutdown(syscall.SHUT_RD)
-}
-
-func (fd *netFD) closeWrite() error {
- return fd.shutdown(syscall.SHUT_WR)
-}
-
-func (fd *netFD) Read(p []byte) (n int, err error) {
- n, err = fd.pfd.Read(p)
- runtime.KeepAlive(fd)
- return n, wrapSyscallError("read", err)
-}
-
-func (fd *netFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error) {
- n, sa, err = fd.pfd.ReadFrom(p)
- runtime.KeepAlive(fd)
- return n, sa, wrapSyscallError("recvfrom", err)
-}
-
-func (fd *netFD) readMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err error) {
- n, oobn, flags, sa, err = fd.pfd.ReadMsg(p, oob)
- runtime.KeepAlive(fd)
- return n, oobn, flags, sa, wrapSyscallError("recvmsg", err)
-}
-
-func (fd *netFD) Write(p []byte) (nn int, err error) {
- nn, err = fd.pfd.Write(p)
- runtime.KeepAlive(fd)
- return nn, wrapSyscallError("write", err)
-}
-
-func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) {
- n, err = fd.pfd.WriteTo(p, sa)
- runtime.KeepAlive(fd)
- return n, wrapSyscallError("sendto", err)
-}
-
-func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error) {
- n, oobn, err = fd.pfd.WriteMsg(p, oob, sa)
- runtime.KeepAlive(fd)
- return n, oobn, wrapSyscallError("sendmsg", err)
-}
-
func (fd *netFD) accept() (netfd *netFD, err error) {
d, rsa, errcall, err := fd.pfd.Accept()
if err != nil {
@@ -267,15 +201,3 @@ func (fd *netFD) dup() (f *os.File, err error) {
return os.NewFile(uintptr(ns), fd.name()), nil
}
-
-func (fd *netFD) SetDeadline(t time.Time) error {
- return fd.pfd.SetDeadline(t)
-}
-
-func (fd *netFD) SetReadDeadline(t time.Time) error {
- return fd.pfd.SetReadDeadline(t)
-}
-
-func (fd *netFD) SetWriteDeadline(t time.Time) error {
- return fd.pfd.SetWriteDeadline(t)
-}