Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 350397

Summary: SelectChannelConnector does not shutdown gracefully
Product: [RT] Jetty Reporter: Martin Thomson <martin.thomson>
Component: serverAssignee: Michael Gorovoy <mgorovoy>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: jetty-inbox, mgorovoy
Version: 7.4.2   
Target Milestone: 7.2.x   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed Test Harness
none
Updated test harness none

Description Martin Thomson CLA 2011-06-27 01:41:59 EDT
The method SelectChannelConnector.close() does not work properly.  According to the documentation [1], as well as the behaviour of the SocketConnector class, this method should only close the server socket without affecting any existing connections that have already been established.

The the close() method does too much work.  It stops the SelectorManager, which in turn stops all the SelectSets.  To fix the problem, the stopping of the SelectorManager should be moved to the SelectChannelConnector.doStop() method just before calling super.doStop().

The methods can be changed to:

    public synchronized void close() throws IOException
    {
        if (_acceptChannel != null)
            _acceptChannel.close();
        _acceptChannel = null;
        _localPort = -2;
    }

    @Override
    protected synchronized void doStop() throws Exception
    {
        if (_manager.isRunning())
        {
            try
            {
                _manager.stop();
            }
            catch (Exception e)
            {
                Log.warn(e);
            }
        }
        super.doStop();
    }


[1] http://docs.codehaus.org/display/JETTY/How+to+gracefully+shutdown
Comment 1 Michael Gorovoy CLA 2011-07-05 21:51:36 EDT
Created attachment 199152 [details]
Proposed Test Harness

Attached is the proposed test harness. It eventually will become a base class for the test harnesses for different types of connectors.
Comment 2 Michael Gorovoy CLA 2011-07-06 00:08:13 EDT
Created attachment 199155 [details]
Updated test harness

New version of test harness. Connector is now closed between pipelined requests in addition to between chunks.
Comment 3 Michael Gorovoy CLA 2011-07-11 14:34:29 EDT
Committed 2011-07-07. 

Need to take a second look at the test harness to make it computer speed-independent. Right now it uses the timeouts that are too small if computer is too busy or too slow.
Comment 4 Michael Gorovoy CLA 2011-07-21 14:48:59 EDT
Improved test harness has been committed for Jetty v7.5.0.