ProtocolCodec.readRegister 优化
This commit is contained in:
@@ -114,7 +114,8 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
channel.readRegisterInIOThread(this);
|
||||
//channel.readRegisterInIOThread(this);
|
||||
channel.readRegister(this);
|
||||
} catch (Exception te) {
|
||||
channel.dispose(); // response.init(channel); 在调用之前异常
|
||||
if (context.logger.isLoggable(Level.FINEST)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class Request<C extends Context> {
|
||||
|
||||
// 请求包是否完成读取完毕,用于ProtocolCodec继续读的判断条件
|
||||
// 需要在readHeader方法中设置
|
||||
protected boolean completed;
|
||||
protected boolean readCompleted;
|
||||
|
||||
protected int pipelineIndex;
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class Request<C extends Context> {
|
||||
pipelineIndex = 0;
|
||||
pipelineCount = 0;
|
||||
pipelineCompleted = false;
|
||||
completed = false;
|
||||
readCompleted = false;
|
||||
keepAlive = false;
|
||||
attributes.clear();
|
||||
annotations = null;
|
||||
|
||||
@@ -348,7 +348,7 @@ public abstract class Response<C extends Context, R extends Request<C>> {
|
||||
AsyncConnection conn = removeChannel();
|
||||
if (conn != null && conn.protocolCodec != null) {
|
||||
this.responseConsumer.accept(this);
|
||||
if (!request.completed) {
|
||||
if (!request.readCompleted) {
|
||||
conn.readRegister(conn.protocolCodec);
|
||||
this.readRegistered = true;
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
// 文件上传必须设置keepAlive为false,因为文件过大时用户不一定会skip掉多余的数据
|
||||
this.keepAlive = false;
|
||||
}
|
||||
// completed=true时ProtocolCodec会继续读下一个request
|
||||
this.completed = !this.boundary && !maybews;
|
||||
// readCompleted=true时ProtocolCodec会继续读下一个request
|
||||
this.readCompleted = !this.boundary && !maybews;
|
||||
this.bodyBytes.clear();
|
||||
this.readState = READ_STATE_BODY;
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
return -1;
|
||||
}
|
||||
this.traceid = this.header.getTraceid();
|
||||
// completed=true时ProtocolCodec会继续读下一个request
|
||||
this.completed = true;
|
||||
// readCompleted=true时ProtocolCodec会继续读下一个request
|
||||
this.readCompleted = true;
|
||||
this.readState = READ_STATE_BODY;
|
||||
}
|
||||
// ---------------------body----------------------------------
|
||||
|
||||
Reference in New Issue
Block a user