Problems persist in KQueueSelectorProvider (Mac) in 7u6 ea
David M. Lloyd
david.lloyd at redhat.com
Fri Aug 10 17:29:52 PDT 2012
On 08/10/2012 06:36 PM, David M. Lloyd wrote:
> We're consistently seeing issues under load on Mac with
> KQueueSelectorProvider.
>
> There are two possibly related symptoms: the KQueueSelectorImpl is going
> into a mode where select() does not block, despite the continued
> emptiness of the selected key set; and FileDispatcherImpl#preClose0 is
> hanging, presumably in dup2(), trying to close a socket.
>
> My current hypothesis that some evil race condition exists and is being
> tripped between kqueue and dup2 (a relatively rare way to close a
> socket, at least until NIO came along I guess). My thought though is
> that sockets should not be preclosed this way: instead it would be
> better to use shutdown(fd, SHUT_RDWR), which would effectively preclose
> the socket and hopefully dodge this issue.
>
> I'm hopefully going to have time to try out a patch which does this, but
> I'm taking a couple weeks off starting tonight so I may not have time,
> so we shall see.
Just took a sec and did up this patch:
diff --git a/src/solaris/classes/sun/nio/ch/SocketDispatcher.java
b/src/solaris/classes/sun/nio/ch/SocketDispatcher.java
index 1c5f8ef..d7933a8 100644
--- a/src/solaris/classes/sun/nio/ch/SocketDispatcher.java
+++ b/src/solaris/classes/sun/nio/ch/SocketDispatcher.java
@@ -56,6 +56,6 @@ class SocketDispatcher extends NativeDispatcher
}
void preClose(FileDescriptor fd) throws IOException {
- FileDispatcherImpl.preClose0(fd);
+ Net.shutdown(fd, Net.SHUT_RDWR);
}
}
The good news is that it doesn't hang in preClose0 anymore (of
course!)... the bad news is, now it hangs in close0, which seems to
imply the problem is occuring when the socket is closed in the kernel.
This, BTW, is the problem which seems to be related to the process being
permanently frozen in "E" (exiting) state.
--
- DML
More information about the nio-dev
mailing list