< prev index next >
src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaSocketChannelImpl.java
Print this page
rev 52804 : [mq]: nullBinding
rev 52801 : imported patch jdk12-8195160-version23.patch
*** 33,43 ****
import java.net.InetSocketAddress;
import java.net.ProtocolFamily;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketOption;
- import java.net.StandardProtocolFamily;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.AlreadyBoundException;
import java.nio.channels.AlreadyConnectedException;
import java.nio.channels.AsynchronousCloseException;
--- 33,42 ----
*** 45,67 ****
import java.nio.channels.ConnectionPendingException;
import java.nio.channels.NoConnectionPendingException;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import sun.net.ext.RdmaSocketOptions;
import sun.nio.ch.IOStatus;
import sun.nio.ch.IOUtil;
- import sun.nio.ch.Net;
import sun.nio.ch.NativeThread;
import sun.nio.ch.SelChImpl;
import sun.nio.ch.SelectionKeyImpl;
public class RdmaSocketChannelImpl
extends SocketChannel
implements SelChImpl
{
--- 44,69 ----
import java.nio.channels.ConnectionPendingException;
import java.nio.channels.NoConnectionPendingException;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
+ import java.nio.channels.UnsupportedAddressTypeException;
import java.nio.channels.spi.SelectorProvider;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import sun.net.ext.RdmaSocketOptions;
import sun.nio.ch.IOStatus;
import sun.nio.ch.IOUtil;
import sun.nio.ch.NativeThread;
+ import sun.nio.ch.Net;
import sun.nio.ch.SelChImpl;
import sun.nio.ch.SelectionKeyImpl;
+ import static java.net.StandardProtocolFamily.INET;
+ import static java.net.StandardProtocolFamily.INET6;
public class RdmaSocketChannelImpl
extends SocketChannel
implements SelChImpl
{
*** 110,142 ****
protected RdmaSocketChannelImpl(SelectorProvider sp, ProtocolFamily family)
throws IOException {
super(checkSupported(sp));
! Objects.requireNonNull(family, "'family' is null");
! if ((family != StandardProtocolFamily.INET) &&
! (family != StandardProtocolFamily.INET6)) {
! throw new UnsupportedOperationException(
! "Protocol family not supported");
}
! if (family == StandardProtocolFamily.INET6) {
if (!Net.isIPv6Available()) {
throw new UnsupportedOperationException("IPv6 not available");
}
}
this.family = family;
this.fd = RdmaNet.socket(family, true);
this.fdVal = IOUtil.fdVal(fd);
}
! RdmaSocketChannelImpl(SelectorProvider sp, FileDescriptor fd,
InetSocketAddress isa) throws IOException {
super(checkSupported(sp));
! this.family = Net.isIPv6Available()
! ? StandardProtocolFamily.INET6
! : StandardProtocolFamily.INET;
this.fd = fd;
this.fdVal = IOUtil.fdVal(fd);
synchronized (stateLock) {
this.localAddress = RdmaNet.localAddress(fd);
this.remoteAddress = isa;
--- 112,141 ----
protected RdmaSocketChannelImpl(SelectorProvider sp, ProtocolFamily family)
throws IOException {
super(checkSupported(sp));
! Objects.requireNonNull(family, "null family");
! if (!(family == INET || family == INET6)) {
! throw new UnsupportedOperationException("Protocol family not supported");
}
! if (family == INET6) {
if (!Net.isIPv6Available()) {
throw new UnsupportedOperationException("IPv6 not available");
}
}
this.family = family;
this.fd = RdmaNet.socket(family, true);
this.fdVal = IOUtil.fdVal(fd);
}
! RdmaSocketChannelImpl(SelectorProvider sp,
! FileDescriptor fd,
InetSocketAddress isa) throws IOException {
super(checkSupported(sp));
! this.family = Net.isIPv6Available() ? INET6 : INET;
this.fd = fd;
this.fdVal = IOUtil.fdVal(fd);
synchronized (stateLock) {
this.localAddress = RdmaNet.localAddress(fd);
this.remoteAddress = isa;
*** 473,482 ****
--- 472,490 ----
synchronized (stateLock) {
return remoteAddress;
}
}
+ private final InetSocketAddress anyLocalAddress() throws IOException {
+ if (family == INET)
+ return new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0);
+ else if (family == INET6)
+ return new InetSocketAddress(InetAddress.getByName("::"), 0);
+ else
+ throw new UnsupportedAddressTypeException();
+ }
+
@Override
public SocketChannel bind(SocketAddress local) throws IOException {
readLock.lock();
try {
writeLock.lock();
*** 485,496 ****
ensureOpen();
if (state == ST_CONNECTIONPENDING)
throw new ConnectionPendingException();
if (localAddress != null)
throw new AlreadyBoundException();
! InetSocketAddress isa = (local == null) ?
! new InetSocketAddress(0)
: RdmaNet.checkAddress(local, family);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkListen(isa.getPort());
}
--- 493,504 ----
ensureOpen();
if (state == ST_CONNECTIONPENDING)
throw new ConnectionPendingException();
if (localAddress != null)
throw new AlreadyBoundException();
! InetSocketAddress isa = (local == null)
! ? anyLocalAddress()
: RdmaNet.checkAddress(local, family);
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkListen(isa.getPort());
}
< prev index next >