Author: remm
Date: Wed May 30 08:07:46 2018
New Revision: 1832519
URL: http://svn.apache.org/viewvc?rev=1832519&view=rev
Log:
Add missing timeout on handshake IO operations for NIO2.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1832519&r1=1832518&r2=1832519&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Wed May
30 08:07:46 2018
@@ -255,10 +255,11 @@ public class SecureNio2Channel extends N
return 0;
} else {
if (async) {
- sc.write(netOutBuffer, socket,
handshakeWriteCompletionHandler);
+ sc.write(netOutBuffer,
Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
+ TimeUnit.MILLISECONDS, socket,
handshakeWriteCompletionHandler);
} else {
try {
-
sc.write(netOutBuffer).get(endpoint.getConnectionTimeout(),
+
sc.write(netOutBuffer).get(Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
throw new
IOException(sm.getString("channel.nio.ssl.handshakeError"));
@@ -289,10 +290,11 @@ public class SecureNio2Channel extends N
if (handshakeStatus != HandshakeStatus.NEED_UNWRAP ||
netOutBuffer.remaining() > 0) {
//should actually return OP_READ if we have NEED_UNWRAP
if (async) {
- sc.write(netOutBuffer, socket,
handshakeWriteCompletionHandler);
+ sc.write(netOutBuffer,
Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
+ TimeUnit.MILLISECONDS, socket,
handshakeWriteCompletionHandler);
} else {
try {
-
sc.write(netOutBuffer).get(endpoint.getConnectionTimeout(),
+
sc.write(netOutBuffer).get(Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException
| TimeoutException e) {
throw new
IOException(sm.getString("channel.nio.ssl.handshakeError"));
@@ -317,10 +319,11 @@ public class SecureNio2Channel extends N
}
//read more data
if (async) {
- sc.read(netInBuffer, socket,
handshakeReadCompletionHandler);
+ sc.read(netInBuffer,
Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
+ TimeUnit.MILLISECONDS, socket,
handshakeReadCompletionHandler);
} else {
try {
- int read =
sc.read(netInBuffer).get(endpoint.getConnectionTimeout(),
+ int read =
sc.read(netInBuffer).get(Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
TimeUnit.MILLISECONDS).intValue();
if (read == -1) {
throw new EOFException();
@@ -563,7 +566,7 @@ public class SecureNio2Channel extends N
sslEngine.closeOutbound();
try {
- if (!flush().get(endpoint.getConnectionTimeout(),
+ if
(!flush().get(Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
TimeUnit.MILLISECONDS).booleanValue()) {
throw new
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"));
}
@@ -584,7 +587,7 @@ public class SecureNio2Channel extends N
netOutBuffer.flip();
//if there is data to be written
try {
- if (!flush().get(endpoint.getConnectionTimeout(),
+ if
(!flush().get(Nio2Endpoint.toNio2Timeout(endpoint.getConnectionTimeout()),
TimeUnit.MILLISECONDS).booleanValue()) {
throw new
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"));
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1832519&r1=1832518&r2=1832519&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed May 30 08:07:46 2018
@@ -158,6 +158,9 @@
Fix a couple of unlikely edge cases in the shutting down of the
APR/native connector. (markt)
</fix>
+ <fix>
+ Add missing handshake timeout for NIO2. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]