Jetty9 - Set stopTimeout to zero by default, and setting defaults for threaded component that need a non-zero stop timeout to stop properly.
This commit is contained in:
parent
136f7924fd
commit
c3dfd0c653
|
@ -268,6 +268,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
public ManagedSelector(int id)
|
||||
{
|
||||
_id = id;
|
||||
setStopTimeout(5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.server;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.AsynchronousCloseException;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -172,7 +173,12 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
for (Thread thread : _acceptors)
|
||||
{
|
||||
if (thread != null)
|
||||
{
|
||||
thread.interrupt();
|
||||
long stopTimeout = getStopTimeout();
|
||||
if (stopTimeout > 0)
|
||||
thread.join(stopTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
super.doStop();
|
||||
|
@ -273,9 +279,10 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
{
|
||||
accept(_acceptor);
|
||||
}
|
||||
catch (IOException | InterruptedException e)
|
||||
catch (AsynchronousCloseException | InterruptedException e)
|
||||
{
|
||||
logger.ignore(e);
|
||||
break;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
|
|
@ -304,7 +304,6 @@ public class Server extends HandlerWrapper implements Attributes
|
|||
|
||||
MultiException mex=new MultiException();
|
||||
|
||||
// TODO: review this logic ...
|
||||
long stopTimeout = getStopTimeout();
|
||||
if (stopTimeout>0)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class AbstractLifeCycle implements LifeCycle
|
|||
private final Object _lock = new Object();
|
||||
private final int __FAILED = -1, __STOPPED = 0, __STARTING = 1, __STARTED = 2, __STOPPING = 3;
|
||||
private volatile int _state = __STOPPED;
|
||||
private long _stopTimeout = 10000;
|
||||
private long _stopTimeout = 0;
|
||||
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
|
|
|
@ -81,6 +81,7 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
setMinThreads(minThreads);
|
||||
setMaxThreads(maxThreads);
|
||||
setMaxIdleTimeMs(maxIdleTimeMs);
|
||||
setStopTimeout(5000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,6 +111,8 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo
|
|||
super.doStop();
|
||||
long start=System.currentTimeMillis();
|
||||
|
||||
// TODO: review the stop logic avoiding sleep(1), and eventually using Thread.interrupt() + thread.join()
|
||||
|
||||
// let jobs complete naturally for a while
|
||||
while (_threadsStarted.get()>0 && (System.currentTimeMillis()-start) < (getStopTimeout()/2))
|
||||
Thread.sleep(1);
|
||||
|
|
Loading…
Reference in New Issue