-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: net: ReadMsgUnix without source address #72068
Comments
For your use case, why do you need to use |
In order to handle Unix file descriptors being sent along with the messages. From the dbus spec: The oob mechanism for the unix socket is only returened with |
Maybe we should start with a variant of |
That seems reasonable to me. |
x/sys/unix has at least the following functions that return a
The most general is In C it is possible to receive messages without getting an address by just passing Perhaps we could add another // RecvmsgAnon is like RecvmsgBuffers but does not return the sender address.
func RecvmsgAnon(fd int, buffers [][]byte, oob []byte, flags int) (n, oobn int, recvflags int, err error) |
Proposal Details
Problem
Currently,
(*UnixConn) ReadMsgUnix()
reads a message from a unix socket, and returns a*UnixAddress
even when the calling code doesn't care about the source address. This allocation isn't optimized out by the compiler even when the calling code specifies _ for the return because it is referenced in some intermediate layers.Proposed Solution
Create
(*UnixConn) ReadMsgUnixIgnoreSource()
that returns(n, oobn, flags int, err error)
and the required underlying functions to support this so that programs that do not care about the source address don't allocate unused data on each call.Usecase
I'm trying to optimize dbus calls which require multiple calls to ReadMsgUnix per dbus message and I am trying to support this on a limited memory (embedded) system. So any time I can save not allocating and GC'ing is an improvement.
The text was updated successfully, but these errors were encountered: