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