harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Regis Xu (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6312) Concurrency problems in NIO
Date Fri, 28 Aug 2009 02:04:59 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12748644#action_12748644
] 

Regis Xu commented on HARMONY-6312:
-----------------------------------

Jesse, do you mean the lock in interestOpsNoCheck ? The method is also used by processSelectResult
which doesn't synchronized on keyLock.

The new prepareChannels() is a little heavy than old code. It uses three loops, one count
numReadable/Writeable, two consutruct readableFDs/writableFDs. The two construct loop can
be merged to one:
<code>
            // populate the readable and writeable FDs, including the mock channel
            int r = 0;
            int w = 0;
            readableFDs[r] = sourcefd;
            readyKeys[r] = null;
            r++;
            for (SelectionKeyImpl key : mutableKeys) {
                int op = key.interestOpsNoCheck();
                FileDescriptor fd = ((FileDescriptorHandler) key.channel()).getFD();
                if ((ACCEPT_OR_READ & op) != 0) {
                    readableFDs[r] = fd;
                    readyKeys[r] = key;
                    r++;
                }
                if ((CONNECT_OR_WRITE & op) != 0) {
                    writableFDs[w] = fd;
                    readyKeys[w + numReadable] = key;
                    w++;
                }
            }
</code>

And if we can count numReadable/Writeable correctly when changing interestOps and canceling
keys, the counting loop can be saved.

> Concurrency problems in NIO
> ---------------------------
>
>                 Key: HARMONY-6312
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6312
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: SVN Revision: 801399
>            Reporter: Jesse Wilson
>            Assignee: Mark Hindess
>         Attachments: cancelledkey.diff, NIO_Concurrency_issues.patch
>
>   Original Estimate: 72h
>  Remaining Estimate: 72h
>
> There's several potential concurrency problems in our NIO implementation...
>  - Charset#isSupported isn't synchronized, but it accesses mutable member cachedCharsetTable.
>  - In SelectionKeyImpl, stHash++ is a non-atomic operation so multiple SelectionKey instances
may receive the same hash code. (Why not use the default hash code?)
>  - In SelectorImpl, the unmodifiableKeys member is never synchronized on. But the documentation
specifies that clients can synchronize on that set to guard against changes
> These are the obvious problems; I suspect there are more subtle concurrency defects at
play here. I'll prepare a patch to address the major issues, and we should consider a rigorous
approach (Findbugs?) to discover concurrency problems.
> #Android

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


Mime
View raw message