Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: syscall: add Conn and RawConn interfaces #19435

Closed
mikioh opened this issue Mar 7, 2017 · 8 comments
Closed

proposal: syscall: add Conn and RawConn interfaces #19435

mikioh opened this issue Mar 7, 2017 · 8 comments

Comments

@mikioh
Copy link
Contributor

mikioh commented Mar 7, 2017

Please take a look at the discussion: https://groups.google.com/d/msg/golang-dev/tcl_XFLUfcE/V6JUoZD-DAAJ

The story is like the following:

  • As described in x/net/{icmp,ipv4,ipv6}: replumbing in the net and internal/poll packages of go1.9 #19051, Go 1.9 breaks a few packages in golang.org/x/net repository,
  • Yikes, I've just remembered that there's inherent fragility due to the runtime reflection hack. Let's fix it at the same time,
  • How to repair the breakage? Looks like the required functionality traverses the net, internal/poll and syscall packages. Where is the best place to patch up?
  • Do it in the syscall package, plus a bit in the net and internal/poll packages,
  • Wait, can we add something new into the locked down package?
  • No problem, because it's about exposing new functionality from the standard library for helping itself.
@mikioh mikioh added this to the Go1.9 milestone Mar 7, 2017
@mikioh
Copy link
Contributor Author

mikioh commented Mar 7, 2017

The detail of the proposed APIs by Mr. Cox is the following:

package syscall

type RawConn interface {
        Control(f func(fd uintptr)) error
        Read(f func(fd uintptr) (done bool)) error
        Write(f func(fd uintptr) (done bool)) error
}

type Conn interface {
        SyscallConn() (syscall.RawConn, error)
}

and then an implementation of a net.Conn may optionally implement syscall.Conn to provide access to its fd as a syscall.RawConn.

@gopherbot
Copy link

CL https://golang.org/cl/37039 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/37913 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/37038 mentions this issue.

@mikioh
Copy link
Contributor Author

mikioh commented Apr 8, 2017

@rsc,

What's the current status of this proposal?

@rsc
Copy link
Contributor

rsc commented May 17, 2017

LGTM here and on the CL.

gopherbot pushed a commit that referenced this issue May 19, 2017
This change adds RawControl, RawRead and RawWrite methods to type FD
to make the runtime-integrated network poller work together with a
user-defined function. The methods are used via the net package from
external packages and type FD is considered as an implementation of
syscall.Conn and syscall.RawConn interfaces.

Updates #19435.

Change-Id: I4ad04b10ffddb2b54fa8d70587440960d73c0a2d
Reviewed-on: https://go-review.googlesource.com/37038
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue May 19, 2017
This change makes {TCP,UDP,IP,Unix}Conn types compliant of
syscall.Conn interface and adds type rawConn as an implementation of
syscall.RawConn interface.

By this change, the long-standing issues regarding unsupported socket
options and system calls can be solved partly and the broken x/net
packages due to https://go-review.googlesource.com/36799 can be
repaired.

Fixes #3661.
Updates #9661.
Updates #19051.
Updates #19435.

Change-Id: Ic996b040418b54f6d043bc70591789d5a5b23270
Reviewed-on: https://go-review.googlesource.com/37039
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue May 20, 2017
This is a followup to https://go-review.googlesource.com/37038.

Updates #19435.

Change-Id: If3d56bca0e8816d1a169f5cf97f27b20695a9955
Reviewed-on: https://go-review.googlesource.com/43692
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue May 20, 2017
This is a followup to https://go-review.googlesource.com/37039.

Updates #19435.

Change-Id: Ia795bd5158d26effa56e897698208ccf73f9e0d2
Reviewed-on: https://go-review.googlesource.com/43693
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/71651 mentions this issue: net: make {TCP,UDP}Listener implement syscall.Conn

gopherbot pushed a commit that referenced this issue Oct 25, 2017
This change adds the syscall.Conn interface to Listener types, with the caveat that only RawConn.Control is supported. Custom socket options can now be set safely.

Updates #19435
Fixes #22065

Change-Id: I7e74780d00318dc54a923d1c628a18a36009acab
Reviewed-on: https://go-review.googlesource.com/71651
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/107395 mentions this issue: net: add missing deadline test for RawConn

gopherbot pushed a commit that referenced this issue Apr 16, 2018
Updates #19435.

Change-Id: Ife4a31972b05094a86c60a48fcacdfe52d133ee4
Reviewed-on: https://go-review.googlesource.com/107395
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Apr 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants