Patch for adding SO_REUSEPORT socket option

Alan Bateman Alan.Bateman at oracle.com
Wed Feb 10 18:37:57 UTC 2016


On 05/02/2016 17:27, Lu, Yingqi wrote:
> Hi Alan,
>
> Here is the new modification of the patch. The link is available here:
> http://cr.openjdk.java.net/~mcberg/jdk/6432031/webrev.10/
>
> In this version, we make supportedOptions() in AbstractPlainSocketImpl and AbstractPlainDatagramSocketImpl return an immutable set of the socket options. In addition, we corrected couple formatting issues.
>
> Please let us know your feedback and comments.
>
I've looked through the latest revision. Just a couple of small things:

In MulticastSocket then a small typo (in two places) where you have 
"SO_REUSPORT" instead of "SO_REUSEPORT". Also it links to 
setOption(int,Object) then I assume it should be 
setOption(SocketOption,Object).

In AbstractPlainSocketImpl and AbstractPlainDatagramSocketImpl then 
supportedOptions looks technically correct but there is no need to 
create an unmodifiableSet on each call to supportedOptions. Instead you 
can simply do:

Set<SocketOption<?>> options = socketOptions;
if (options == null) {
     if (isReusePortAvailable()) {
         options = new HashSet<>();
         options.addAll(super.supportedOptions());
         options.add(StandardSocketOptions.SO_REUSEPORT);
         options = Collections.unmodifiableSet(options);
     } else {
         options = super.supportedOptions();
     }
     socketOptions = options;
}
return options;

I don't see any other issues at this time and I'm happy to sponsor and 
help you get this in.

-Alan.





More information about the net-dev mailing list