Skip to content

Commit

Permalink
Revert "net, internal/syscall/unix: add SocketConn, SocketPacketConn"
Browse files Browse the repository at this point in the history
This reverts commit 6f7961d.

Russ suggests changing the frozon syscall package and obviously it's a
better solution. Perhaps he will also let me know the way how to get the
project owners to agree later.

Fixes #11492.

Change-Id: I98f9f366b72b85db54b4acfc3a604b62fb6d783c
Reviewed-on: https://go-review.googlesource.com/11854
Run-TryBot: Mikio Hara <[email protected]>
Reviewed-by: Rob Pike <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
  • Loading branch information
cixtor authored and bradfitz committed Jul 2, 2015
1 parent 8593871 commit 2a0fc9e
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 609 deletions.
2 changes: 1 addition & 1 deletion src/go/build/deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ var pkgDeps = map[string][]string{
// Basic networking.
// Because net must be used by any package that wants to
// do networking portably, it must have a small dependency set: just L1+basic os.
"net": {"L1", "CGO", "os", "syscall", "time", "internal/syscall/unix", "internal/syscall/windows", "internal/singleflight"},
"net": {"L1", "CGO", "os", "syscall", "time", "internal/syscall/windows", "internal/singleflight"},

// NET enables use of basic network-related packages.
"NET": {
Expand Down
39 changes: 0 additions & 39 deletions src/internal/syscall/unix/socket.go

This file was deleted.

67 changes: 0 additions & 67 deletions src/internal/syscall/unix/socket_linux_386.go

This file was deleted.

11 changes: 0 additions & 11 deletions src/internal/syscall/unix/socket_linux_386.s

This file was deleted.

25 changes: 0 additions & 25 deletions src/internal/syscall/unix/socket_stub.go

This file was deleted.

59 changes: 0 additions & 59 deletions src/internal/syscall/unix/socket_unix.go

This file was deleted.

51 changes: 0 additions & 51 deletions src/net/fd_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package net

import (
"internal/syscall/unix"
"io"
"os"
"runtime"
Expand Down Expand Up @@ -271,33 +270,6 @@ func (fd *netFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error) {
return
}

func (fd *netFD) recvFrom(b []byte, flags int, from []byte) (n int, err error) {
if err := fd.readLock(); err != nil {
return 0, err
}
defer fd.readUnlock()
if err := fd.pd.PrepareRead(); err != nil {
return 0, err
}
for {
n, err = unix.Recvfrom(fd.sysfd, b, flags, from)
if err != nil {
n = 0
if err == syscall.EAGAIN {
if err = fd.pd.WaitRead(); err == nil {
continue
}
}
}
err = fd.eofError(n, err)
break
}
if _, ok := err.(syscall.Errno); ok {
err = os.NewSyscallError("recvfrom", err)
}
return
}

func (fd *netFD) readMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.Sockaddr, err error) {
if err := fd.readLock(); err != nil {
return 0, 0, 0, nil, err
Expand Down Expand Up @@ -387,29 +359,6 @@ func (fd *netFD) writeTo(p []byte, sa syscall.Sockaddr) (n int, err error) {
return
}

func (fd *netFD) sendTo(b []byte, flags int, to []byte) (n int, err error) {
if err := fd.writeLock(); err != nil {
return 0, err
}
defer fd.writeUnlock()
if err := fd.pd.PrepareWrite(); err != nil {
return 0, err
}
for {
n, err = unix.Sendto(fd.sysfd, b, flags, to)
if err == syscall.EAGAIN {
if err = fd.pd.WaitWrite(); err == nil {
continue
}
}
break
}
if _, ok := err.(syscall.Errno); ok {
err = os.NewSyscallError("sendto", err)
}
return
}

func (fd *netFD) writeMsg(p []byte, oob []byte, sa syscall.Sockaddr) (n int, oobn int, err error) {
if err := fd.writeLock(); err != nil {
return 0, 0, err
Expand Down
44 changes: 0 additions & 44 deletions src/net/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,47 +46,3 @@ func FilePacketConn(f *os.File) (c PacketConn, err error) {
}
return
}

// A SocketAddr is used with SocketConn or SocketPacketConn to
// implement a user-configured socket address.
// The net package does not provide any implementations of SocketAddr;
// the caller of SocketConn or SocketPacketConn is expected to provide
// one.
type SocketAddr interface {
// Addr takes a platform-specific socket address and returns
// a net.Addr. The result may be nil when the syscall package,
// system call or underlying protocol does not support the
// socket address.
Addr([]byte) Addr

// Raw takes a net.Addr and returns a platform-specific socket
// address. The result may be nil when the syscall package,
// system call or underlying protocol does not support the
// socket address.
Raw(Addr) []byte
}

// SocketConn returns a copy of the network connection corresponding
// to the open file f and user-defined socket address sa.
// It is the caller's responsibility to close f when finished.
// Closing c does not affect f, and closing f does not affect c.
func SocketConn(f *os.File, sa SocketAddr) (c Conn, err error) {
c, err = socketConn(f, sa)
if err != nil {
err = &OpError{Op: "file", Net: "file+net", Source: nil, Addr: fileAddr(f.Name()), Err: err}
}
return
}

// SocketPacketConn returns a copy of the packet network connection
// corresponding to the open file f and user-defined socket address
// sa.
// It is the caller's responsibility to close f when finished.
// Closing c does not affect f, and closing f does not affect c.
func SocketPacketConn(f *os.File, sa SocketAddr) (c PacketConn, err error) {
c, err = socketPacketConn(f, sa)
if err != nil {
err = &OpError{Op: "file", Net: "file+net", Source: nil, Addr: fileAddr(f.Name()), Err: err}
}
return
}
Loading

0 comments on commit 2a0fc9e

Please sign in to comment.