This commit is contained in:
Redkale
2018-04-18 18:30:03 +08:00
parent 76debd5c82
commit ace4042649
3 changed files with 11 additions and 4 deletions

View File

@@ -64,6 +64,7 @@ public final class PrepareRunner implements Runnable {
try {
response.request.offerReadBuffer(buffer);
response.finish(true);
channel.close();// response.init(channel); 在调用之前异常
} catch (Exception e) {
if (context.logger.isLoggable(Level.FINEST)) {
context.logger.log(Level.FINEST, "PrepareRunner close channel erroneous on no read bytes", e);
@@ -91,6 +92,10 @@ public final class PrepareRunner implements Runnable {
public void failed(Throwable exc, Void attachment2) {
response.request.offerReadBuffer(buffer);
response.finish(true);
try { // response.init(channel); 可能在调用之前异常
channel.close();
} catch (Exception e) {
}
if (exc != null && context.logger.isLoggable(Level.FINEST)) {
context.logger.log(Level.FINEST, "Servlet Handler read channel erroneous, forece to close channel ", exc);
}
@@ -99,6 +104,10 @@ public final class PrepareRunner implements Runnable {
} catch (Exception te) {
response.request.offerReadBuffer(buffer);
response.finish(true);
try { // response.init(channel); 可能在调用之前异常
channel.close();
} catch (Exception e) {
}
if (te != null && context.logger.isLoggable(Level.FINEST)) {
context.logger.log(Level.FINEST, "Servlet read channel erroneous, forece to close channel ", te);
}

View File

@@ -91,7 +91,7 @@ public abstract class Request<C extends Context> {
createtime = 0;
keepAlive = false;
attributes.clear();
channel = null; // close it by response
channel = null; // close it by response
}
protected <T> T setProperty(String name, T value) {

View File

@@ -184,9 +184,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
request.recycle();
if (channel != null) {
if (keepAlive) {
this.inited = false;
new PrepareRunner(context, removeChannel(), null, this).run();
return false;
this.context.runAsync(new PrepareRunner(context, channel, null, null));
} else {
try {
if (channel.isOpen()) channel.close();