You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Ray Chen (JIRA)" <ji...@apache.org> on 2009/11/13 08:01:39 UTC
[jira] Created: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
[classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HARMONY-6375
URL: https://issues.apache.org/jira/browse/HARMONY-6375
Project: Harmony
Issue Type: Bug
Components: Classlib
Environment: All platforms
Reporter: Ray Chen
As the summary described:
One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another thread
try to configure the block mode on one channel
Posted by Ray Chen <cl...@gmail.com>.
How about add wait(100) and nofity() in configureBlocking() method to break
the deadlock?
And should the timeout be shorter to avoid impacting the performance?
--
Regards,
Ray Chen
Re: [jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another thread
try to configure the block mode on one channel
Posted by Ray Chen <cl...@gmail.com>.
Hi Mark,
Sorry for the "getPort()", and I have updated the testcase to version 2, the
"getPort()" has been erased from my memory too now :) .
On Fri, Nov 13, 2009 at 5:40 PM, Mark Hindess
<ma...@googlemail.com>wrote:
>
> In message <55...@brutus>, "Ray Chen
> (JIRA)"
> writes:
> >
> > Ray Chen updated HARMONY-6375:
> > ------------------------------
> >
> > Attachment: Harmony6375TestCase.java
> >
> > It is a test case which can reproduce the problem
> >
> > > [classlib][nio]ServerSocketChannel hang when the main thread is
> > > waiting for request to accept and another thread try to configure
> > > the block mode on one channel
>
>
> Please help save me from unstable tests! Please delete getPort() and
> do what you can to erase it from your memory. ;-)
>
> My comment on HARMONY-6324 applies equally to this test case (except you
> don't even need to get the OS assigned address/port back since it isn't
> used). See also:
>
>
> http://tellison.blogspot.com/2009/09/programming-sockets-using-temporary.html
>
> Regards,
> Mark.
>
>
>
--
Regards,
Ray Chen
Re: [jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
Posted by Mark Hindess <ma...@googlemail.com>.
In message <55...@brutus>, "Ray Chen (JIRA)"
writes:
>
> Ray Chen updated HARMONY-6375:
> ------------------------------
>
> Attachment: Harmony6375TestCase.java
>
> It is a test case which can reproduce the problem
>
> > [classlib][nio]ServerSocketChannel hang when the main thread is
> > waiting for request to accept and another thread try to configure
> > the block mode on one channel
Please help save me from unstable tests! Please delete getPort() and
do what you can to erase it from your memory. ;-)
My comment on HARMONY-6324 applies equally to this test case (except you
don't even need to get the OS assigned address/port back since it isn't
used). See also:
http://tellison.blogspot.com/2009/09/programming-sockets-using-temporary.html
Regards,
Mark.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6375:
------------------------------
Attachment: Harmony6375TestCase.java
It is a test case which can reproduce the problem
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony6375TestCase.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6375:
------------------------------
Attachment: Harmony-6375_V2.diff
Hi Mark,
How about this new version patch?
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Attachments: Harmony-6375.diff, Harmony-6375_V2.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Hindess resolved HARMONY-6375.
-----------------------------------
Resolution: Fixed
Applied patch in r921764. Please confirm (by closing this JIRA) that it has been applied as expected.
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Attachments: Harmony-6375.diff, Harmony-6375_V2.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841699#action_12841699 ]
Ray Chen commented on HARMONY-6375:
-----------------------------------
Hi Charles,
I modified my testcase by adding two statements and ran it on RI:
...
System.out.println(channel1.isBlocking());
channel1.configureBlocking(false);
System.out.println(channel1.isBlocking());
...
The output showed that the blocking mode has been changed from "true" to "false"
And I also ran the test case on harmony which has applied my patch,
the behavior is same as RI's.
However, in our implementation I found following code in
ServerSocketChannelImpl.java
protected void implConfigureBlocking(boolean blockingMode)
throws IOException {
// Do nothing here. For real accept() operation in nonblocking mode,
// it uses INetworkSystem.select. Whether a channel is blocking can be
// decided by isBlocking() method.
}
See? Actually it just changes the flag in java code.
For RI, is it also a flag? Or really change the mode in native code?
We can not know.
--
Regards,
Ray Chen
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Hindess updated HARMONY-6375:
----------------------------------
Assignee: Mark Hindess
Patch looks good but it would be good to have a regression test if possible.
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Hudson (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844021#action_12844021 ]
Hudson commented on HARMONY-6375:
---------------------------------
Integrated in Harmony-1.5-head-linux-x86_64 #661 (See [http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/661/])
Applying patches from "[#] [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel".
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Fix For: 6.0M2, 5.0M14
>
> Attachments: Harmony-6375.diff, Harmony-6375_V2.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen closed HARMONY-6375.
-----------------------------
Patch verified! Thanks Mark!
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Fix For: 6.0M2, 5.0M14
>
> Attachments: Harmony-6375.diff, Harmony-6375_V2.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6375:
------------------------------
Attachment: Harmony-6375.diff
In the ServerSocketChannelImpl.java, it holds the blockingLock, and because it is in blocking mode, so the accept() keep waiting. But in another thread which want to change the blocking mode, it also want to hold the blockingLock in the configureBlocking(boolean) method, which result in a deadLock.
In the patch, I simply remove the sychronized block to resolve the thread deadlock because the bolckingLock has been synchronized in blockingLock() method located in AbstractSelectableChannel.
This patch can make the test pass and no new test failures found in luni and nio unit tests.
I wonder, does this change hava any side effect?
If the main thread got the blocking mode and release the blockingLock, then before the main thread do the real IO operations, another thread change the blocking mode, what behavior it should be?
I found following description in the spec of the InterruptibleChannel interface says:
"A channel that implements this interface is asynchronously closeable: If a thread is blocked in an I/O operation on an interruptible channel then another thread may invoke the channel's close method. This will cause the blocked thread to receive an AsynchronousCloseException."
Any comments?
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6375:
------------------------------
Patch Info: [Patch Available]
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ray Chen updated HARMONY-6375:
------------------------------
Attachment: Harmony6375TestCase_V2.java
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Li Jing Qin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841696#action_12841696 ]
Li Jing Qin commented on HARMONY-6375:
--------------------------------------
Hi Ray,
What does the RI behave if one is accepting and another is trying to change the block mode?
>From the native aspect, when accept is called for a blocking socket, it should be blocked. So if we have configure it as block and accept, the process should be put to sleep. During this sleep, if we change the blocking mode, it should not have any affect.
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Hindess updated HARMONY-6375:
----------------------------------
Fix Version/s: 5.0M14
6.0M2
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Assignee: Mark Hindess
> Fix For: 6.0M2, 5.0M14
>
> Attachments: Harmony-6375.diff, Harmony-6375_V2.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6375) [classlib][nio]ServerSocketChannel
hang when the main thread is waiting for request to accept and another
thread try to configure the block mode on one channel
Posted by "Li Jing Qin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841736#action_12841736 ]
Li Jing Qin commented on HARMONY-6375:
--------------------------------------
Hi Ray,
I have misunderstood your test case. It should throw AsynchronousCloseException when another thread close the Channel. If you comment out the ssc.configureBlocking line, harmony and ri all works well.
About configureBlocking mode: if you comment out the ssc.close line, you will find that ssc.accept still wait for a connection, even though it is set to NON_BLOCKING. It is kind of reasonable from the native view but unreason from the java view.
Any way, I agree your patch.
One more thing, ServerSocketChannelImpl use select to fake the NON_BLOCKING, but SocketChannel set flag on fd to support the NON_BLOCKING. Does anyone know where does this difference come from?
> [classlib][nio]ServerSocketChannel hang when the main thread is waiting for request to accept and another thread try to configure the block mode on one channel
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: HARMONY-6375
> URL: https://issues.apache.org/jira/browse/HARMONY-6375
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Environment: All platforms
> Reporter: Ray Chen
> Attachments: Harmony-6375.diff, Harmony6375TestCase.java, Harmony6375TestCase_V2.java
>
>
> As the summary described:
> One thread is waiting for request to accept and another thread is trying to configure the block mode on the same channel.
> I will attach one test case file to describe the problem.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.