You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Regis Xu (JIRA)" <ji...@apache.org> on 2009/06/05 05:03:07 UTC

[jira] Created: (HARMONY-6225) [classlib][nio] epoll selector provider throw RuntimeException when selecting

[classlib][nio] epoll selector provider throw RuntimeException when selecting
-----------------------------------------------------------------------------

                 Key: HARMONY-6225
                 URL: https://issues.apache.org/jira/browse/HARMONY-6225
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M9
            Reporter: Regis Xu


the test case:

        Selector selector = Selector.open();
        SocketChannel channel1 = SocketChannel.open();
        channel1.configureBlocking(false);
        channel1.register(selector, SelectionKey.OP_READ);
        channel1.close();

        SocketChannel channel2 = SocketChannel.open();
        channel2.configureBlocking(false);
        channel2.register(selector, SelectionKey.OP_READ);
        
        channel2.keyFor(selector).cancel();
        
        selector.selectNow();

It passed on RI and org.apache.harmony.nio.internal.SelectorImpl provider, but throw RuntimeException:
Exception in thread "main" java.lang.RuntimeException
	at org.apache.harmony.nio.internal.EpollSelectorImpl.delKey(EpollSelectorImpl.java:247)
	at org.apache.harmony.nio.internal.EpollSelectorImpl.doCancel(EpollSelectorImpl.java:477)
	at org.apache.harmony.nio.internal.EpollSelectorImpl.selectInternal(EpollSelectorImpl.java:361)
	at org.apache.harmony.nio.internal.EpollSelectorImpl.selectNow(EpollSelectorImpl.java:353)
	at EpollBug.main(EpollBug.java:25)

After some investigations, I found epoll selector used a "quickMap" to keep the mapping from FD to SelectionKey. It use operation system FD value as the key which is got by resolveFD method. Unfortunately FD value is not unique, OS will reuse the value if the old one is closed. So in the test, channel1 and channel2 have the different SelectionKey but the same FD value, the conflict cause unexpected behaviors.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.