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
x/sys/unix: add RecvmsgBuffers and SendmsgBuffers #52885
Comments
I agree, these seem like useful functions to have in |
Minor nit: I suggest renaming |
I think the general historical trend has been to mimic the C API names. SGTM on adding these functions. |
Since we spelled out net.Buffers for a [][]byte, should we call this Buffers instead of Bufs too? |
This proposal has been added to the active column of the proposals project |
I could be wrong, but it is my understanding that the reason why net.Buffers is a named type is that it has two methods attached (it implements Reader and WriterTo). I don't think that's required or even desirable here. |
We're not going to actually use |
Thanks for the clarification.
|
I think we should probably spell out Buffers but otherwise it sounds like no one objects to this. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/412496 mentions this issue: |
Change https://go.dev/cl/412497 mentions this issue: |
Every other Iovec.Base field is *byte, and that is the only reasonable value for Go. This is not backward compatible but we've made changes like this before. For golang/go#52885 Change-Id: I9a313a7931966a2483a322edd5c06c8cdca2557a Reviewed-on: https://go-review.googlesource.com/c/sys/+/412496 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
Change https://go.dev/cl/419914 mentions this issue: |
Don't shadow the empty var when determining whether to send a single byte when iovecs are empty but oob is non-empty. This will lead to the n value correctly being reset to 0 before return. No test because it's not possible to trigger this case on all platforms, e.g. darwin where sendmsg with empty buf and non-empty oob returns EINVAL. This was introduced by CL 412497 and CL 419396. Updates golang/go#52885 Change-Id: Iafc5a4b22e10b396ba5f7d4f2ac1c50df195a125 Reviewed-on: https://go-review.googlesource.com/c/sys/+/419914 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
The golang.org/x/sys/unix package was created with
Recvmsg
andSendmsg
functions copied from the ones in the syscall package. Those date back to https://go.dev/cl/2331044, committed in 2010 for #1101. Unfortunately, thoseRecvmsg
andSendmsg
functions do not correspond to therecvmsg
andsendmsg
system calls. The system calls take a pointer to aMsghdr
struct. TheRecvmsg
andSendmsg
functions build aMsghdr
instance, but they don't support the full functionality ofrecvmsg
andsendmsg
: they don't permit setting up the scatter/gather array.Working directly with a
Msghdr
is awkward for the x/sys/unix routines. It seems better to provide some translation for the socket address. Still, we should provide access to the scatter/gather array. I propose the following:Part of the goal of these functions is to simply the golang.org/x/net/internal/socket package, which currently reaches into the syscall package for
syscall.recvmsg
andsyscall.sendmsg
.CC @tklauser @mdlayher
The text was updated successfully, but these errors were encountered: