Merge branch '3.2.x'
This commit is contained in:
commit
f16d940081
|
@ -67,25 +67,15 @@ final class GracefulShutdown {
|
||||||
List<Connector> connectors = getConnectors();
|
List<Connector> connectors = getConnectors();
|
||||||
connectors.forEach(this::close);
|
connectors.forEach(this::close);
|
||||||
shutdownUnderway.countDown();
|
shutdownUnderway.countDown();
|
||||||
try {
|
awaitInactiveOrAborted();
|
||||||
for (Container host : this.tomcat.getEngine().findChildren()) {
|
if (this.aborted) {
|
||||||
for (Container context : host.findChildren()) {
|
logger.info("Graceful shutdown aborted with one or more requests still active");
|
||||||
while (!this.aborted && isActive(context)) {
|
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
||||||
Thread.sleep(50);
|
|
||||||
}
|
|
||||||
if (this.aborted) {
|
|
||||||
logger.info("Graceful shutdown aborted with one or more requests still active");
|
|
||||||
callback.shutdownComplete(GracefulShutdownResult.REQUESTS_ACTIVE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (InterruptedException ex) {
|
else {
|
||||||
Thread.currentThread().interrupt();
|
logger.info("Graceful shutdown complete");
|
||||||
|
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
||||||
}
|
}
|
||||||
logger.info("Graceful shutdown complete");
|
|
||||||
callback.shutdownComplete(GracefulShutdownResult.IDLE);
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
shutdownUnderway.countDown();
|
shutdownUnderway.countDown();
|
||||||
|
@ -105,6 +95,22 @@ final class GracefulShutdown {
|
||||||
connector.getProtocolHandler().closeServerSocketGraceful();
|
connector.getProtocolHandler().closeServerSocketGraceful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void awaitInactiveOrAborted() {
|
||||||
|
try {
|
||||||
|
for (Container host : this.tomcat.getEngine().findChildren()) {
|
||||||
|
for (Container context : host.findChildren()) {
|
||||||
|
while (!this.aborted && isActive(context)) {
|
||||||
|
Thread.sleep(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isActive(Container context) {
|
private boolean isActive(Container context) {
|
||||||
try {
|
try {
|
||||||
if (((StandardContext) context).getInProgressAsyncCount() > 0) {
|
if (((StandardContext) context).getInProgressAsyncCount() > 0) {
|
||||||
|
|
Loading…
Reference in New Issue