From fb40b046fd43711aea7acebec94ecc9d4a07f89b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 28 Sep 2009 16:54:49 -0600 Subject: [PATCH] fix regression in SocketSelector when selecting ServerSocketChannels --- classpath/java/nio/channels/SelectableChannel.java | 2 ++ classpath/java/nio/channels/ServerSocketChannel.java | 4 ++++ classpath/java/nio/channels/SocketSelector.java | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/classpath/java/nio/channels/SelectableChannel.java b/classpath/java/nio/channels/SelectableChannel.java index a49d6a292b..161fa497f2 100644 --- a/classpath/java/nio/channels/SelectableChannel.java +++ b/classpath/java/nio/channels/SelectableChannel.java @@ -16,6 +16,8 @@ import java.nio.ByteBuffer; public abstract class SelectableChannel implements Channel { private SelectionKey key; + abstract int socketFD(); + public abstract SelectableChannel configureBlocking(boolean v) throws IOException; diff --git a/classpath/java/nio/channels/ServerSocketChannel.java b/classpath/java/nio/channels/ServerSocketChannel.java index 5ddbdc0f16..178e0bbed1 100644 --- a/classpath/java/nio/channels/ServerSocketChannel.java +++ b/classpath/java/nio/channels/ServerSocketChannel.java @@ -23,6 +23,10 @@ public class ServerSocketChannel extends SelectableChannel { return new ServerSocketChannel(); } + public int socketFD() { + return channel.socketFD(); + } + public SelectableChannel configureBlocking(boolean v) throws IOException { return channel.configureBlocking(v); } diff --git a/classpath/java/nio/channels/SocketSelector.java b/classpath/java/nio/channels/SocketSelector.java index 79d01d8594..0b7c1d6b4b 100644 --- a/classpath/java/nio/channels/SocketSelector.java +++ b/classpath/java/nio/channels/SocketSelector.java @@ -72,7 +72,7 @@ class SocketSelector extends Selector { it.hasNext();) { SelectionKey key = it.next(); - SocketChannel c = (SocketChannel)key.channel(); + SelectableChannel c = key.channel(); int socket = c.socketFD(); if (c.isOpen()) { key.readyOps(0); @@ -88,7 +88,7 @@ class SocketSelector extends Selector { if (r > 0) { for (SelectionKey key : keys) { - SocketChannel c = (SocketChannel)key.channel(); + SelectableChannel c = key.channel(); int socket = c.socketFD(); int ready = natUpdateReadySet(socket, key.interestOps(), state); key.readyOps(ready);