From f807e15c775f60c1fe375e79b48a1d8f42fa54bb Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 1 Feb 2011 01:57:12 +0000 Subject: [PATCH] 335329 Stop SSL spin during handshake and renogotiate git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2719 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../eclipse/jetty/client/HttpConnection.java | 4 +++- .../io/nio/SslSelectChannelEndPoint.java | 20 ++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index d2d8bd814e7..4448c08cd45 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -28,6 +28,7 @@ jetty-7.3.0-SNAPSHOT + 334062 It should be possible to embed in the jetty.home.bundle the ssl keystore files + 334229 javax-security needs to import the package javax.security.cert in its OSGi manifest + 334311 fix buffer reuse issue in CachedExchange + + 335329 Stop SSL spin during handshake and renogotiate + 335361 Fixed 'jetty.sh check' to show current PID when JETTY_PID env. variable is set + 335641 Cleaned up dispatch handling to avoid key.interestOps==0 when undispatched + 335681 Improve ChannelEndPoint.close() to avoid spinning diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java index d37f54adc19..993348b52b5 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java @@ -265,7 +265,7 @@ public class HttpConnection implements Connection if (io > 0) no_progress = 0; - else if (no_progress++ >= 2 && !_endp.isBlocking()) + else if (no_progress++ >= 1 && !_endp.isBlocking()) { // SSL may need an extra flush as it may have made "no progress" while actually doing a handshake. if (_endp instanceof SslSelectChannelEndPoint && !_generator.isComplete() && !_generator.isEmpty()) @@ -406,8 +406,10 @@ public class HttpConnection implements Connection _exchange.disassociate(); } + // Do we have more stuff to write? if (!_generator.isComplete() && _generator.getBytesBuffered()>0 && _endp instanceof AsyncEndPoint) { + // Assume we are write blocked! ((AsyncEndPoint)_endp).setWritable(false); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java index fa5e1b50b45..feacf9a646a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java @@ -937,7 +937,25 @@ public class SslSelectChannelEndPoint extends SelectChannelEndPoint { return _engine; } - + + /* ------------------------------------------------------------ */ + @Override + public void setWritable(boolean writable) + { + // only set !writable if we are not waiting for input + if (writable || !HandshakeStatus.NEED_UNWRAP.equals(_engine.getHandshakeStatus()) || super.isBufferingOutput()) + super.setWritable(writable); + } + + /* ------------------------------------------------------------ */ + @Override + public void scheduleWrite() + { + // only set !writable if we are not waiting for input + if (!HandshakeStatus.NEED_UNWRAP.equals(_engine.getHandshakeStatus()) || super.isBufferingOutput()) + super.scheduleWrite(); + } + /* ------------------------------------------------------------ */ @Override public String toString()