This commit is contained in:
@@ -223,7 +223,6 @@ public class TcpNioAsyncConnection extends AsyncConnection {
|
||||
return;
|
||||
}
|
||||
this.readPending = true;
|
||||
this.readByteBuffer = pollReadBuffer();
|
||||
if (this.readTimeoutSeconds > 0) {
|
||||
NioCompletionHandler newhandler = new NioCompletionHandler(handler, this.readByteBuffer);
|
||||
this.readCompletionHandler = newhandler;
|
||||
@@ -380,6 +379,12 @@ public class TcpNioAsyncConnection extends AsyncConnection {
|
||||
final boolean invokeDirect = this.ioThread.inSameThread();
|
||||
int totalCount = 0;
|
||||
boolean hasRemain = true;
|
||||
if (invokeDirect && this.readByteBuffer == null) {
|
||||
this.readByteBuffer = pollReadBuffer();
|
||||
if (this.readTimeoutSeconds > 0) {
|
||||
((NioCompletionHandler) this.readCompletionHandler).setAttachment(this.readByteBuffer);
|
||||
}
|
||||
}
|
||||
while (invokeDirect && hasRemain) {
|
||||
int readCount = this.channel.read(readByteBuffer);
|
||||
hasRemain = readByteBuffer.hasRemaining();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class NioCompletionHandler<A> implements CompletionHandler<Integer, A>, R
|
||||
|
||||
private final CompletionHandler<Integer, A> handler;
|
||||
|
||||
private final A attachment;
|
||||
private A attachment;
|
||||
|
||||
public ScheduledFuture timeoutFuture;
|
||||
|
||||
@@ -30,6 +30,10 @@ public class NioCompletionHandler<A> implements CompletionHandler<Integer, A>, R
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
public void setAttachment(A attachment) {
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed(Integer result, A attach) {
|
||||
ScheduledFuture future = this.timeoutFuture;
|
||||
|
||||
Reference in New Issue
Block a user