Author: remm
Date: Fri Apr 11 22:42:43 2014
New Revision: 1586789
URL: http://svn.apache.org/r1586789
Log:
- Possible SSL NIO2 fixes for gather (if there are more than two buffers, which
doesn't really happen) and incomplete netOutBuffer writes (which also shouldn't
happen).
- Try again the SSL test, just in case.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
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=1586789&r1=1586788&r2=1586789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Fri Apr
11 22:42:43 2014
@@ -817,7 +817,7 @@ public class SecureNio2Channel extends N
try {
// Prepare the output buffer
- this.netOutBuffer.clear();
+ netOutBuffer.clear();
// Wrap the source data into the internal buffer
SSLEngineResult result = sslEngine.wrap(src, netOutBuffer);
final int written = result.bytesConsumed();
@@ -827,13 +827,17 @@ public class SecureNio2Channel extends N
tasks();
}
// Write data to the channel
- sc.write(this.netOutBuffer, timeout, unit, attachment,
+ sc.write(netOutBuffer, timeout, unit, attachment,
new CompletionHandler<Integer, A>() {
@Override
public void completed(Integer nBytes, A attach) {
if (nBytes.intValue() < 0) {
failed(new EOFException(), attach);
+ } else if (netOutBuffer.hasRemaining()) {
+ sc.write(netOutBuffer, timeout, unit, attachment,
this);
} else if (written == 0) {
+ // Special case, start over to avoid code
duplication
+ writePending = false;
write(src, timeout, unit, attachment, handler);
} else {
// Call the handler completed method with the
@@ -875,7 +879,7 @@ public class SecureNio2Channel extends N
this.unit = unit;
this.attachment = attachment;
this.handler = handler;
- this.pos = offset + 1;
+ this.pos = offset;
}
public long writeCount = 0;
public int pos;
@@ -894,12 +898,14 @@ public class SecureNio2Channel extends N
if (state.pos == state.offset + state.length) {
writePending = false;
state.handler.completed(Long.valueOf(state.writeCount),
state.attachment);
+ } else if (netOutBuffer.hasRemaining()) {
+ sc.write(netOutBuffer, state.timeout, state.unit, state,
this);
} else {
try {
// Prepare the output buffer
netOutBuffer.clear();
// Wrap the source data into the internal buffer
- SSLEngineResult result =
sslEngine.wrap(state.srcs[state.offset], netOutBuffer);
+ SSLEngineResult result =
sslEngine.wrap(state.srcs[state.pos], netOutBuffer);
int written = result.bytesConsumed();
state.writeCount += written;
netOutBuffer.flip();
@@ -907,8 +913,8 @@ public class SecureNio2Channel extends N
if (result.getHandshakeStatus() ==
HandshakeStatus.NEED_TASK) {
tasks();
}
- if (written > 0) {
- state.offset++;
+ if (!state.srcs[state.pos].hasRemaining()) {
+ state.pos++;
}
// Write data to the channel
sc.write(netOutBuffer, state.timeout, state.unit,
state, this);
@@ -958,6 +964,9 @@ public class SecureNio2Channel extends N
if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
tasks();
}
+ if (!srcs[offset].hasRemaining()) {
+ state.pos++;
+ }
// Write data to the channel
sc.write(netOutBuffer, timeout, unit, state, new
GatherCompletionHandler<>(state));
} else {
Modified:
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java?rev=1586789&r1=1586788&r2=1586789&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
(original)
+++
tomcat/trunk/test/org/apache/tomcat/websocket/TestWebSocketFrameClientSSL.java
Fri Apr 11 22:42:43 2014
@@ -46,11 +46,6 @@ public class TestWebSocketFrameClientSSL
@Test
public void testConnectToServerEndpoint() throws Exception {
- Assume.assumeFalse(
- "Skip this test on NIO2. FIXME: NIO2 SSL only issue.",
- getTomcatInstance().getConnector().getProtocol()
- .equals("org.apache.coyote.http11.Http11Nio2Protocol"));
-
Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
Context ctx =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]