Hello.
I've written sample socket server on Java using java.nio.* and expirienced problem that seemed to be solved here: [http://bugs.sun.com/view_bug.do?bug_id=6403933]. Behaviour is like described in bug report: after some connections Selector doesn't wait a timeout, it executes ten times a millisecond.
According to bug database this should be fixed in 6u4(b02), we have 6u16(b01) and Linux 2.6.28. How come that 6u16 doesn't contain fix added in 6u4? is that possible?
Code goes here:
public void work(long timeout) {
int retval = 0;
try {
retval = m_selector.select(timeout);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
if (retval == 0)
return;
Iterator it = m_selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey key = (SelectionKey)it.next();
it.remove();
if (!key.isAcceptable())
continue;
try {
Socket socket = m_sockl.accept();
System.out.println("socket accepted");
m_workerPool.add(socket);
}
catch (IOException e) {
}
catch (PoolFullException e) {
System.err.println("pool is full");
}
}
}
The function is executed in loop:
while (m_running) {
serverFacade.work(100);
}