RFR: 8231260: (dc) DatagramChannel::disconnect changes the port of the local address to 0 (lnx)

Florian Weimer fweimer at redhat.com
Fri Oct 4 16:25:55 UTC 2019


* Alan Bateman:

> On 04/10/2019 17:03, Florian Weimer wrote:
>> :
>> The kernel will do it atomically during connect, so there is no race
>> condition.  With the change above, the port is selected and opened,
>> packets can arrive (from arbitrary addresses), and only then the socket
>> is bound to the remote address.

> I don't see an issue here as packets in the socket buffer are read and
> discarded after the address association is setup in the kernel.

On Solaris, yes, but historically not on Linux.  I see a flush for the
transmission queue, but not the reception queue.

But given that the DatagramChannelImpl code flushes the queue manually
after connect, that difference really should not matter.

Thanks,
Florian


More information about the nio-dev mailing list