Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Selector bug?

843790Oct 13 2009 — edited Oct 27 2009
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);
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2009
Added on Oct 13 2009
25 comments
393 views