--- a/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Thu Mar 14 14:45:55 2013 +0100
+++ b/jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Thu Mar 14 13:46:15 2013 -0700
@@ -79,6 +79,9 @@
private final ReadWriteLock closeLock = new ReentrantReadWriteLock();
private volatile boolean open = true;
+ // set true when exclusive binding is on and SO_REUSEADDR is emulated
+ private boolean isReuseAddress;
+
AsynchronousSocketChannelImpl(AsynchronousChannelGroupImpl group)
throws IOException
{
@@ -455,7 +458,14 @@
begin();
if (writeShutdown)
throw new IOException("Connection has been shutdown for writing");
- Net.setSocketOption(fd, Net.UNSPEC, name, value);
+ if (name == StandardSocketOptions.SO_REUSEADDR &&
+ Net.useExclusiveBind())
+ {
+ // SO_REUSEADDR emulated when using exclusive bind
+ isReuseAddress = (Boolean)value;
+ } else {
+ Net.setSocketOption(fd, Net.UNSPEC, name, value);
+ }
return this;
} finally {
end();
@@ -472,6 +482,12 @@
try {
begin();
+ if (name == StandardSocketOptions.SO_REUSEADDR &&
+ Net.useExclusiveBind())
+ {
+ // SO_REUSEADDR emulated when using exclusive bind
+ return (T)Boolean.valueOf(isReuseAddress);
+ }
return (T) Net.getSocketOption(fd, Net.UNSPEC, name);
} finally {
end();