diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java | |
parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
download | gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.zip gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.bz2 |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java')
-rw-r--r-- | libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java b/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java index c538ea8..1e8e090 100644 --- a/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java +++ b/libjava/classpath/gnu/java/nio/ServerSocketChannelImpl.java @@ -48,7 +48,9 @@ import java.nio.channels.SocketChannel; import java.nio.channels.spi.SelectorProvider; public final class ServerSocketChannelImpl extends ServerSocketChannel + implements VMChannelOwner { + private VMChannel channel; private NIOServerSocket serverSocket; private boolean connected; @@ -56,13 +58,15 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel throws IOException { super (provider); - serverSocket = new NIOServerSocket (this); + serverSocket = new NIOServerSocket(this); + channel = serverSocket.getPlainSocketImpl().getVMChannel(); configureBlocking(true); } + // XXX do we need this? public void finalizer() { - if (connected) + if (channel.getState().isValid()) { try { @@ -77,12 +81,12 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel protected void implCloseSelectableChannel () throws IOException { connected = false; - serverSocket.close(); + channel.close(); } protected void implConfigureBlocking (boolean blocking) throws IOException { - serverSocket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT); + channel.setBlocking(blocking); } public SocketChannel accept () throws IOException @@ -98,27 +102,28 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel try { begin(); - serverSocket.getPlainSocketImpl().setInChannelOperation(true); - // indicate that a channel is initiating the accept operation - // so that the socket ignores the fact that we might be in - // non-blocking mode. - NIOSocket socket = (NIOSocket) serverSocket.accept(); - completed = true; - return socket.getChannel(); - } - catch (SocketTimeoutException e) - { - return null; + VMChannel client = channel.accept(); + if (client == null) + return null; + else + { + completed = true; + return new SocketChannelImpl(provider(), client, false); + } } finally { - serverSocket.getPlainSocketImpl().setInChannelOperation(false); end (completed); } } - public ServerSocket socket () + public ServerSocket socket() { return serverSocket; } + + public VMChannel getVMChannel() + { + return channel; + } } |