You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2019/05/17 12:46:11 UTC
[tomcat] branch master updated: Attempt to fix APR flush
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 32d8242 Attempt to fix APR flush
32d8242 is described below
commit 32d82429b158d29ea1176fd1b4cb0b548cb9b78c
Author: remm <re...@apache.org>
AuthorDate: Fri May 17 14:46:01 2019 +0200
Attempt to fix APR flush
Fix NPE I saw in maintain. Do a CI run to see the results (will still be
disabled afterwards since the performance is obviously worse).
---
java/org/apache/tomcat/util/net/AprEndpoint.java | 44 ++++++++++--------------
java/org/apache/tomcat/util/net/NioEndpoint.java | 2 +-
2 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java
index a8437cb..9767111 100644
--- a/java/org/apache/tomcat/util/net/AprEndpoint.java
+++ b/java/org/apache/tomcat/util/net/AprEndpoint.java
@@ -122,7 +122,7 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
// - no IO vectoring
// - mandatory use of direct buffers causing required output buffering
// - needs extra output flushes due to the buffering
- setUseAsyncIO(false);
+ //setUseAsyncIO(false);
}
// ------------------------------------------------------------- Properties
@@ -1319,15 +1319,17 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
Long.valueOf(socket)));
}
AprSocketWrapper socketWrapper = connections.get(Long.valueOf(socket));
- socketWrapper.setError(new SocketTimeoutException());
- if (socketWrapper.readOperation != null || socketWrapper.writeOperation != null) {
- if (socketWrapper.readOperation != null) {
- socketWrapper.readOperation.process();
+ if (socketWrapper != null) {
+ socketWrapper.setError(new SocketTimeoutException());
+ if (socketWrapper.readOperation != null || socketWrapper.writeOperation != null) {
+ if (socketWrapper.readOperation != null) {
+ socketWrapper.readOperation.process();
+ } else {
+ socketWrapper.writeOperation.process();
+ }
} else {
- socketWrapper.writeOperation.process();
+ processSocket(socketWrapper, SocketEvent.ERROR, true);
}
- } else {
- processSocket(socketWrapper, SocketEvent.ERROR, true);
}
socket = timeouts.check(date);
}
@@ -2790,11 +2792,6 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
}
return;
}
- if (!read && flush(false)) {
- inline = false;
- registerWriteInterest();
- return;
- }
// Find the buffer on which the operation will be performed (no vectoring with APR)
ByteBuffer buffer = null;
for (int i = 0; i < length; i++) {
@@ -2803,23 +2800,20 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
break;
}
}
- if (buffer == null ) {
+ if (buffer == null) {
// Nothing to do
return;
}
if (read) {
nBytes = read(false, buffer);
} else {
- int remaining = buffer.remaining();
- writeNonBlockingDirect(buffer);
- nBytes = remaining - buffer.remaining();
- if (nBytes > 0) {
- try {
- if (flush(false)) {
- registerWriteInterest();
- }
- } catch (IOException e) {
- // Ignore, will be delayed to later
+ if (!flush(false)) {
+ int remaining = buffer.remaining();
+ writeNonBlockingDirect(buffer);
+ nBytes = remaining - buffer.remaining();
+ if (nBytes > 0 && !buffer.isDirect() && flush(block == BlockingMode.BLOCK)) {
+ inline = false;
+ registerWriteInterest();
}
}
}
@@ -2832,7 +2826,7 @@ public class AprEndpoint extends AbstractEndpoint<Long,Long> implements SNICallB
}
}
if (nBytes > 0) {
- // The bytes read are only updated in the completion handler
+ // The bytes processed are only updated in the completion handler
completion.completed(Long.valueOf(nBytes), this);
} else if (nBytes < 0 || getError() != null) {
IOException error = getError();
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 6b7a9fa..a23448b 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1481,7 +1481,7 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
}
}
if (nBytes > 0) {
- // The bytes read are only updated in the completion handler
+ // The bytes processed are only updated in the completion handler
completion.completed(Long.valueOf(nBytes), this);
} else if (nBytes < 0 || getError() != null) {
IOException error = getError();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org