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