Patch for adding SO_REUSEPORT socket option

Alan Bateman Alan.Bateman at oracle.com
Mon Dec 7 15:04:00 UTC 2015



On 02/12/2015 17:08, Lu, Yingqi wrote:
>
> Hi All,
>
> A quick check here. Does anyone get a chance to try the most recent 
> patch? Any feedback and comments?
>
> Thanks,
>
> Lucy
>
>
I looked through the latest webrev (webrev.05) and it's looking quite good.

I agree with Michael, we should decide whether it make sense to add 
specific methods to Socket/ServerSocket/DatagramSocket. They aren't 
strictly needed and given that the socket option is essentially optional 
then setOption/getOption should be fine.

The updated wording in StandardSocketOptions looks okay but one 
suggestion is to include the word "usually" as it can't mandate the 
behavior on all platforms where it is supported - for example "the 
socket option will usually allow ...". A minor point here is that they 
needs @since 9.

The updates to the NIO implementation classes mostly look okay, except 
sun.nio.ch.Net where I have a number of comments:

1. In Net.java then you'll see where it caches several capabilities, 
that could be used to cache whether this socket option is supported or 
not, no need to do it in native code (Net.c).

2. I see reuseportSupported() is public so that it can be in several 
places (including code in java.net) but would be nice to avoid that.

3. For #1 and #3 then maybe the simplest is to add a native function in 
libnet like we have for IPv6 and that would allow the net and nio code 
to use the same implementation that is consistent with the existing code.

4. Minor comment on Net.c is that you use UNUSED whereas the existing 
code uses "this".

I wonder if it might be simpler to leave the debugger agent out of this, 
I don't see a big reason to change it.

For the tests then it would be good to avoid using 
sun.net.ch.Net.reuseportSupported(). Instead I think it should check 
that supportedOptions returns the right value for the platform.

I assume tests such as MulticastSendReceiveTests don't need to set this 
option.

-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20151207/34962c68/attachment.html>


More information about the net-dev mailing list