[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/31010] New: select() doesn't block with DatagramChannels
From: |
bitclash at gmail dot com |
Subject: |
[Bug classpath/31010] New: select() doesn't block with DatagramChannels |
Date: |
1 Mar 2007 16:31:59 -0000 |
[CLASSPATH 0.90]
The following method from class gnu.java.nio.SelectorImpl :
public abstract int select() throws IOException
doesn't follow the semantic stated by SUN's documentation:
"This method performs a blocking selection operation. It returns only after at
least one channel is selected, this selector's wakeup method is invoked, or the
current thread is interrupted, whichever comes first."
Effectively it doesn't block with a DatagramChannel associated to it. Try the
following proof-of-concept code:
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
public class TestNonBlockingDatagramSocket {
private final static String ADDR = "127.0.0.1";
private final static int PORT = 8888;
public static void main(String args[]) throws Exception {
Selector selector = Selector.open();
DatagramChannel channel = DatagramChannel.open();
channel.socket().bind(new InetSocketAddress(ADDR,PORT));
channel.configureBlocking(false);
channel.register(selector, SelectionKey.OP_READ);
selector.select();
System.out.println("BUG? Select() doesn't block!");
}
}
It blocks correctly with JDK 1.4, 1.5 and 1.6.
--
Summary: select() doesn't block with DatagramChannels
Product: classpath
Version: 0.90
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bitclash at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31010
- [Bug classpath/31010] New: select() doesn't block with DatagramChannels,
bitclash at gmail dot com <=