fix regression in SocketSelector when selecting ServerSocketChannels

This commit is contained in:
Joel Dice 2009-09-28 16:54:49 -06:00
parent 6fa25f992c
commit fb40b046fd
3 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,8 @@ import java.nio.ByteBuffer;
public abstract class SelectableChannel implements Channel { public abstract class SelectableChannel implements Channel {
private SelectionKey key; private SelectionKey key;
abstract int socketFD();
public abstract SelectableChannel configureBlocking(boolean v) public abstract SelectableChannel configureBlocking(boolean v)
throws IOException; throws IOException;

View File

@ -23,6 +23,10 @@ public class ServerSocketChannel extends SelectableChannel {
return new ServerSocketChannel(); return new ServerSocketChannel();
} }
public int socketFD() {
return channel.socketFD();
}
public SelectableChannel configureBlocking(boolean v) throws IOException { public SelectableChannel configureBlocking(boolean v) throws IOException {
return channel.configureBlocking(v); return channel.configureBlocking(v);
} }

View File

@ -72,7 +72,7 @@ class SocketSelector extends Selector {
it.hasNext();) it.hasNext();)
{ {
SelectionKey key = it.next(); SelectionKey key = it.next();
SocketChannel c = (SocketChannel)key.channel(); SelectableChannel c = key.channel();
int socket = c.socketFD(); int socket = c.socketFD();
if (c.isOpen()) { if (c.isOpen()) {
key.readyOps(0); key.readyOps(0);
@ -88,7 +88,7 @@ class SocketSelector extends Selector {
if (r > 0) { if (r > 0) {
for (SelectionKey key : keys) { for (SelectionKey key : keys) {
SocketChannel c = (SocketChannel)key.channel(); SelectableChannel c = key.channel();
int socket = c.socketFD(); int socket = c.socketFD();
int ready = natUpdateReadySet(socket, key.interestOps(), state); int ready = natUpdateReadySet(socket, key.interestOps(), state);
key.readyOps(ready); key.readyOps(ready);