summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2009-01-13 17:29:17 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2009-01-13 17:29:17 +0000
commit218960268571fec8cddcde323b1a4c7e38c0baca (patch)
treea8f12e6e48b3d84b12de378a04cb726183af31d6
parentf87af0c1050cd56aa40da669e97e16a41fab180a (diff)
downloadqpid-python-M4-RCs.tar.gz
This is a fix for QPID-1571M4-RCs
After M4 release we should probably revisit the SSL close logic. The current fix was done with causing as less impact as possible on the tested code paths. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/M4-RCs@734193 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/network/ssl/SSLSender.java44
1 files changed, 41 insertions, 3 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ssl/SSLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ssl/SSLSender.java
index f5bd18d848..5e37d5356b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ssl/SSLSender.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/ssl/SSLSender.java
@@ -62,8 +62,15 @@ public class SSLSender implements Sender<ByteBuffer>
}
log.debug("Closing SSL connection");
engine.closeOutbound();
- send(ByteBuffer.allocate(0));
- flush();
+ try
+ {
+ tearDownSSLConnection();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException("Error closing SSL connection",e);
+ }
+
while (!engine.isOutboundDone())
{
synchronized(engineState)
@@ -82,6 +89,37 @@ public class SSLSender implements Sender<ByteBuffer>
}
}
+ private void tearDownSSLConnection() throws Exception
+ {
+ SSLEngineResult result = engine.wrap(ByteBuffer.allocate(0), netData);
+ Status status = result.getStatus();
+ int read = result.bytesProduced();
+ while (status != Status.CLOSED)
+ {
+ if (status == Status.BUFFER_OVERFLOW)
+ {
+ netData.clear();
+ }
+ if(read > 0)
+ {
+ int limit = netData.limit();
+ netData.limit(netData.position());
+ netData.position(netData.position() - read);
+
+ ByteBuffer data = netData.slice();
+
+ netData.limit(limit);
+ netData.position(netData.position() + read);
+
+ delegate.send(data);
+ flush();
+ }
+ result = engine.wrap(ByteBuffer.allocate(0), netData);
+ status = result.getStatus();
+ read = result.bytesProduced();
+ }
+ }
+
public void flush()
{
delegate.flush();
@@ -92,7 +130,7 @@ public class SSLSender implements Sender<ByteBuffer>
if (closed.get())
{
throw new SenderException("SSL Sender is closed");
- }
+ }
HandshakeStatus handshakeStatus;
Status status;