x/net/{ipv4,ipv6}: MSG_DONTWAIT flag ignored #46891
Labels
FrozenDueToAge
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Setting the flag
syscall.MSG_DONTWAIT
when callingx/net/ipv4.(*PacketConn).WriteBatch
.Example program:
go.mod
What did you expect to see?
If the
MSG_DONTWAIT
flag was honored, the program would print "resource temporary unavailable" as soon as the kernels UDP send buffer fills up.What did you see instead?
The
MSG_DONTWAIT
flag is ignored; the program blocks on eachWriteBatch
call until there is room in the send buffer such that the send operation can be completed.Note: depending on local network speeds and settings, it might be necessary to increase the number of packets sent in the program above.
Additional Notes
The
MSG_DONTWAIT
flag is also ignored forReadBatch
.The effect of passing the
MSG_DONTWAIT
flag is that the system call should returnEAGAIN
/EWOULDBLOCK
when the call would block. This is analogous to theO_NONBLOCK
setting on the socket itself -- as far as I understand, this is always set for sockets in go, as it is part of the network polling. Therefore, the only way to disambiguate this would be to explicitly handle thisMSG_DONTWAIT
flag in the implementation of thex/net
library code. In particular, my suggestion would be:The text was updated successfully, but these errors were encountered: