We see sockets in CLOSE_WAIT when NioReceiver.stop() is called. Apparently, according to; http://forum.java.sun.com/thread.jspa?threadID=478802&messageID=2231353 one must remain registered with the selector, close, then select again (with a timeout), and then the channel is properly drained and a tcp reset occurs. I'm working on a patch.
Ah, forgive me, linger is enabled with a 3 second timeout. In my tests I see them hanging around but if I wait they do close. The pattern for draining the queue completely is still a useful enhancement and would allow correct behavior without linger.
Any progress on your patch?
I believe a patch could look something like Index: org/apache/catalina/tribes/transport/nio/NioReceiver.java =================================================================== --- org/apache/catalina/tribes/transport/nio/NioReceiver.java (revision 695909) +++ org/apache/catalina/tribes/transport/nio/NioReceiver.java (working copy) @@ -377,6 +377,7 @@ log.warn("Unable to cleanup on selector close.",ignore); } }catch ( ClosedSelectorException ignore){} + try {selector.selectNow();}catch (Throwable ignore){} selector.close(); } and all we do, is issue a selectNow statement after we have cancelled the keys best Filip
Filips patch has been applied to 8.0.x for 8.0.15 onwards. I do not propose to back-port this.