Daniel Kulp created AMQ-5269:
--------------------------------

             Summary: NIO transports using blocking accept calls, very slow 
shutdown
                 Key: AMQ-5269
                 URL: https://issues.apache.org/jira/browse/AMQ-5269
             Project: ActiveMQ
          Issue Type: Bug
          Components: Transport
    Affects Versions: 5.10.0
            Reporter: Daniel Kulp
            Assignee: Daniel Kulp



Currently, all the TCP based transports are using the old blocking style of 
socket.accept() to accept connections.   This works "OK" except that for 
sockets that have a channel associated with them, the socket.close() doesn't 
cause it to return immediately.  It still waits for the SoTimeout which is 
currently set a 2 seconds.   That can cause 2 second delays for any shutdown 
which causes long, unnecessary delays, particularly in the tests.

One possible "fix" is to drop the socket.setSoTimeout(2000) call to something 
much smaller.   However, that would turn the accept thread into a more "busy 
wait" scenario which is undesirable.

A better fix is to change the accepts for the sockets that have a 
ServerSocketChannel to use the NIO based selectors for the accept operations.   
The selector.disable()/selector.close() allows the socket and everything to 
close immediately.  The result is that the NIO based tests now take the same 
amount of time as the non-NIO based tests (for which socket.close() causes the 
accept to return immediately).

Pull request forthcoming.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to