connect() method behavior during asynchronous close

Alan Bateman Alan.Bateman at Sun.COM
Thu May 15 05:29:18 PDT 2008


Umashankar wrote:
> Hi Alan,
> In one of my AsynchronousSocketChannel tests, I am testing the 
> behavior of the connect() method in the event of an asynchronous close 
> of the socket channel.
> The test sometimes hangs on windows. I did jstack -l <pid> on the hung 
> process. I don't see any deadlocks in the thread dump.
> Attached is the thread dump of the hung process.
>
> Please let me know if there is a bug.
>
You are right and there is bug here. The deadlock isn't obvious at first 
glance but the stack trace for Thread-0 reveals all. It is trying to 
close the channel (which requires the channel's write lock) while 
holding the read lock as it updates the socket properties after the 
connection is established. You are right that it is Windows specific and 
furthermore this does appear to be the only case where this can happen. 
The fix is simple and I'll include it in the next build. Thanks for 
persevering with these tests to flush out these lurking issues.

-Alan.



More information about the nio-dev mailing list