RFR 8231187: SelectorProvider.inheritedChannel() returns TCP socket channel for Unix domain socket
Alan Bateman
Alan.Bateman at oracle.com
Fri Sep 20 10:42:19 UTC 2019
On 20/09/2019 10:53, Michael McMahon wrote:
> Hi,
>
> This issue was reported through a recent discussion proposing an API
> for Unix domain
> sockets. It fixes the current erroneous behavior where TCP type
> SocketChannels are returned
> and instead returns a Channel type which handles connected AF_UNIX
> sockets specifically.
>
> The fix also enables the whole inherited channel mechanism for Mac,
> which up to now
> has not been working.
>
> http://cr.openjdk.java.net/~michaelm/8231187/webrev.1/index.html
Yes, I remember that bug came up in the proposal to add the API so it's
good to get it fixed.
I skimmed through the webrev. The async close doesn't look right, mostly
missing preClose and the final close by the last thread doing I/O. The
Unix implementation of SourceChannelImpl or SinkChannelImpl are the
simplest examples to follow if you need it. The main issues are:
- need a state field to track that the channel is closing
- endRead need to close the channel when the state is_ST_CLOSING and
there is no writer (the opposite for reader)
- implCloseChannel should only close if reader and writer are both 0,
otherwise it should preClose and signal the reader and/or writer.
A minor nit is that getFDVal can be removed, and getFD can be private as
the channel doesn't implement SelChImpl.
As a precaultion, createChannel could return null if the address family
is AF_UKNOWN.
-Alan.
More information about the nio-dev
mailing list