harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r987461 - in /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main: java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java native/jsse/shared/sslSocket.c native/jsse/shared/sslSocket.h
Date Fri, 20 Aug 2010 11:45:07 GMT
Author: odeakin
Date: Fri Aug 20 11:45:07 2010
New Revision: 987461

URL: http://svn.apache.org/viewvc?rev=987461&view=rev
Log:
Implement close() method to shutdown the SSL connection. Removing class members that are no
longer used.

Modified:
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.c
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.h

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java?rev=987461&r1=987460&r2=987461&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
Fri Aug 20 11:45:07 2010
@@ -47,10 +47,6 @@ public class SSLSocketImpl extends SSLSo
     // indicates if handshake has been started
     private boolean handshake_started = false;
 
-    // record protocol to be used
-    protected SSLRecordProtocol recordProtocol;
-    // alert protocol to be used
-    private AlertProtocol alertProtocol;
     // application data input stream, this stream is presented by
     // ssl socket as an input stream. Additionaly this object is a
     // place where application data will be stored by record protocol
@@ -530,6 +526,8 @@ public class SSLSocketImpl extends SSLSo
         init();
     }
     
+
+    private static native void closeImpl(long ssl);
     /**
      * This method works according to the specification of implemented class.
      * @see javax.net.ssl.SSLSocket#close()
@@ -542,17 +540,12 @@ public class SSLSocketImpl extends SSLSo
         }
         // TODO: Call down into natives to close down OpenSSL connection an clean up structs
         if (!socket_was_closed) {
-            if (handshake_started) {
-                alertProtocol.alert(AlertProtocol.WARNING,
-                        AlertProtocol.CLOSE_NOTIFY);
-                try {
-                    output.write(alertProtocol.wrap());
-                } catch (IOException ex) { }
-                alertProtocol.setProcessed();
+            if (SSL != 0) {
+                closeImpl(SSL);
             }
-            shutdown();
             closeTransportLayer();
             socket_was_closed = true;
+            SSL = 0;
         }
     }
 
@@ -602,18 +595,6 @@ public class SSLSocketImpl extends SSLSo
 
     // -----------------------------------------------------------------
 
-    // Shutdownes the ssl socket and makes all cleanup work.
-    private void shutdown() {
-        if (handshake_started) {
-            alertProtocol.shutdown();
-            alertProtocol = null;
-            recordProtocol.shutdown();
-            recordProtocol = null;
-        }
-        socket_was_closed = true;
-    }
-
-
     private native byte needAppDataImpl(long ssl);
 
     /**

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.c?rev=987461&r1=987460&r2=987461&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.c
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.c
Fri Aug 20 11:45:07 2010
@@ -144,3 +144,13 @@ JNIEXPORT jbyte JNICALL Java_org_apache_
 
     return data;
 }
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_closeImpl
+  (JNIEnv *env, jclass clazz, jlong jssl) {
+    SSL *ssl = jlong2addr(SSL, jssl);
+
+    // The SSLSocket is being closed, so shutdown and free our SSL
+    SSL_shutdown(ssl);
+    SSL_free(ssl);
+}
+

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.h?rev=987461&r1=987460&r2=987461&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.h
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslSocket.h
Fri Aug 20 11:45:07 2010
@@ -33,6 +33,8 @@ JNIEXPORT void JNICALL Java_org_apache_h
   (JNIEnv *, jclass, jlong, jbyteArray, jint, jint);
 JNIEXPORT jbyte JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_needAppDataImpl
   (JNIEnv *, jclass, jlong);
+JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_closeImpl
+  (JNIEnv *, jclass, jlong);
 
 #ifdef __cplusplus
 }



Mime
View raw message