This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new d2752e5 Improve NIO2 flush
d2752e5 is described below
commit d2752e595136a08f5c64908103fa274559ee78ca
Author: remm <[email protected]>
AuthorDate: Mon May 20 14:11:04 2019 +0200
Improve NIO2 flush
Although it probably will never happen, also use the additional write
buffers when flushing.
---
java/org/apache/tomcat/util/net/Nio2Endpoint.java | 43 ++++++++++++++---------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
index e1ab5d0..767253a 100644
--- a/java/org/apache/tomcat/util/net/Nio2Endpoint.java
+++ b/java/org/apache/tomcat/util/net/Nio2Endpoint.java
@@ -1032,25 +1032,34 @@ public class Nio2Endpoint extends
AbstractJsseEndpoint<Nio2Channel,AsynchronousS
} else {
// If there is still data inside the main write buffer, it
needs to be written first
if (!socketBufferHandler.isWriteBufferEmpty()) {
- socketBufferHandler.configureWriteBufferForRead();
-
getSocket().write(socketBufferHandler.getWriteBuffer(), null, new
CompletionHandler<Integer, Void>() {
- @Override
- public void completed(Integer nBytes, Void
attachment) {
- if (nBytes.intValue() < 0) {
- failed(new EOFException(), null);
- } else {
- // Continue until everything is written
- run();
- }
- }
- @Override
- public void failed(Throwable exc, Void attachment)
{
- completion.failed(exc,
Nio2OperationState.this);
+ synchronized (writeCompletionHandler) {
+ socketBufferHandler.configureWriteBufferForRead();
+ ByteBuffer[] array =
nonBlockingWriteBuffer.toArray(socketBufferHandler.getWriteBuffer());
+ if (arrayHasData(array)) {
+ getSocket().write(array, 0, array.length,
timeout, unit,
+ array, new CompletionHandler<Long,
ByteBuffer[]>() {
+ @Override
+ public void completed(Long nBytes,
ByteBuffer[] buffers) {
+ if (nBytes.longValue() < 0) {
+ failed(new EOFException(),
null);
+ } else if
(arrayHasData(buffers)) {
+ getSocket().write(array,
0, array.length, toTimeout(getWriteTimeout()),
+
TimeUnit.MILLISECONDS, array, this);
+ } else {
+ // Continue until
everything is written
+ process();
+ }
+ }
+ @Override
+ public void failed(Throwable exc,
ByteBuffer[] buffers) {
+ completion.failed(exc,
Nio2OperationState.this);
+ }
+ });
+ return;
}
- });
- } else {
- getSocket().write(buffers, offset, length, timeout,
unit, this, completion);
+ }
}
+ getSocket().write(buffers, offset, length, timeout, unit,
this, completion);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]