This is an automated email from the ASF dual-hosted git repository.
markt 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 40ca9be Fix timeout handling. Write timeout could be handled as read
timeout.
40ca9be is described below
commit 40ca9bef10a2c2db48e759b16fc4fbff3725ffca
Author: Mark Thomas <[email protected]>
AuthorDate: Sat Nov 16 16:43:52 2019 +0000
Fix timeout handling. Write timeout could be handled as read timeout.
---
java/org/apache/tomcat/util/net/NioEndpoint.java | 15 ++++++++-------
webapps/docs/changelog.xml | 4 ++++
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 1e5b900..090b26a 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -953,24 +953,25 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
cancelledKey(key, socketWrapper);
} else if ((socketWrapper.interestOps() &
SelectionKey.OP_READ) == SelectionKey.OP_READ ||
(socketWrapper.interestOps() &
SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
- boolean isTimedOut = false;
boolean readTimeout = false;
boolean writeTimeout = false;
// Check for read timeout
if ((socketWrapper.interestOps() &
SelectionKey.OP_READ) == SelectionKey.OP_READ) {
long delta = now - socketWrapper.getLastRead();
long timeout = socketWrapper.getReadTimeout();
- isTimedOut = timeout > 0 && delta > timeout;
- readTimeout = true;
+ if (timeout > 0 && delta > timeout) {
+ readTimeout = true;
+ }
}
// Check for write timeout
- if (!isTimedOut && (socketWrapper.interestOps() &
SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
+ if (!readTimeout && (socketWrapper.interestOps() &
SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) {
long delta = now -
socketWrapper.getLastWrite();
long timeout = socketWrapper.getWriteTimeout();
- isTimedOut = timeout > 0 && delta > timeout;
- writeTimeout = true;
+ if (timeout > 0 && delta > timeout) {
+ writeTimeout = true;
+ }
}
- if (isTimedOut) {
+ if (readTimeout || writeTimeout) {
key.interestOps(0);
// Avoid duplicate timeout calls
socketWrapper.interestOps(0);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c209d6e..c60f634 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -57,6 +57,10 @@
<add>
<bug>63835</bug>: Add support for Keep-Alive response header.
(michaelo)
</add>
+ <fix>
+ Correct a logic bug in the <code>NioEndpoint</code> timeout handling
+ that meant a write timeout could be handled as a read timeout. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]