Behaviour of SocketChannelImpl.close() in Java11 (ea+12)

Alan Bateman Alan.Bateman at oracle.com
Sun May 13 07:36:29 UTC 2018


On 11/05/2018 20:40, Norman Maurer wrote:
> :
> Interesting enough I never noticed this javadoc and just assumed it would work the same way as when I just do it via C, which also works for non-blocking sockets (at least with SO_LINGER 0).
>
The awkward case is enabling linger to a value > 0 as that means the 
underlying close(2) may potentially block. This gets problematic for 
selection operations that may have to close a lot of sockets (due to 
close being called on channels registered with the Selector).

There was no intention to break the SO_LINGER = 0 case when this code 
was refactored a few months ago. We can get that working again, at least 
for cases where the closed channels are promptly flushed from the 
Selectors that they are registered with. I have changes that I will 
bring here for review soon.

-Alan.


More information about the nio-dev mailing list