harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r999967 - in /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main: java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java native/jsse/shared/sslEngine.c native/jsse/shared/sslEngine.h
Date Wed, 22 Sep 2010 14:20:04 GMT
Author: odeakin
Date: Wed Sep 22 14:20:04 2010
New Revision: 999967

URL: http://svn.apache.org/viewvc?rev=999967&view=rev
Log:
Add check for a shutdown state and set engine state appropriately.

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

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.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/SSLEngineImpl.java?rev=999967&r1=999966&r2=999967&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
Wed Sep 22 14:20:04 2010
@@ -79,7 +79,7 @@ public class SSLEngineImpl extends SSLEn
     private static native long initSSLEngine(long context);
     private static native HandshakeStatus connectImpl(long ssl);
     private static native HandshakeStatus acceptImpl(long ssl);
-    private static native SSLEngineResult wrapImpl(long sslEngineAddress,
+    private static native SSLEngineResult wrapImpl(long ssl, long sslEngineAddress,
             long src_address, int src_len, long dst_address, int dst_len);
     private static native SSLEngineResult unwrapImpl(long ssl, long sslEngineAddress,
             long src_address, int src_len, long dst_address, int dst_len);
@@ -570,7 +570,7 @@ public class SSLEngineImpl extends SSLEn
             dst_address = AddressUtil.getDirectBufferAddress(dst_temp_buffer);
         }
         
-        SSLEngineResult result = wrapImpl(SSLEngineAddress, src_address, src_length, dst_address,
dst_length);
+        SSLEngineResult result = wrapImpl(SSL, SSLEngineAddress, src_address, src_length,
dst_address, dst_length);
         
         // update the buffers contents and positions
         srcs[0].position(srcs[0].position() + result.bytesConsumed());

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.c?rev=999967&r1=999966&r2=999967&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.c
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.c
Wed Sep 22 14:20:04 2010
@@ -130,13 +130,13 @@ JNIEXPORT jobject JNICALL Java_org_apach
 }
 
 JNIEXPORT jobject JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLEngineImpl_wrapImpl
-  (JNIEnv *env, jclass clazz, jlong jsslengine, jlong src_address, int src_len, 
+  (JNIEnv *env, jclass clazz, jlong jssl, jlong jsslengine, jlong src_address, int src_len,

   jlong dst_address, int dst_len) {
     _sslengine *sslengine = jlong2addr(_sslengine, jsslengine);
     BIO *bio = sslengine->bio;
     BIO *bio_io = sslengine->bio_io;
-    SSL *ssl = NULL;
-    int write_result = 0, read_result = 0;
+    SSL *ssl = jlong2addr(SSL, jssl);
+    int write_result = 0, read_result = 0, shutdownState = 0;
     jobject handshake_state = NULL, engine_state = NULL, result = NULL;
     jclass result_class;
     jmethodID result_constructor;
@@ -144,7 +144,6 @@ JNIEXPORT jobject JNICALL Java_org_apach
     jbyte *dst_buffer = jlong2addr(jbyte, dst_address);
     int initial_init_state, init_state;
 
-    BIO_get_ssl(bio, &ssl);
     initial_init_state = SSL_in_init(ssl);
     
     // write input data
@@ -162,6 +161,12 @@ JNIEXPORT jobject JNICALL Java_org_apach
         handshake_state = handshake_need_unwrap;
         engine_state = engine_ok;
     }
+
+    // Check if close_notify has been sent or received
+    shutdownState = SSL_get_shutdown(ssl);
+    if (shutdownState) {
+        engine_state = engine_closed;
+    }
     
     // read output data
     read_result = BIO_read(bio_io, dst_buffer, dst_len);
@@ -198,8 +203,8 @@ JNIEXPORT jobject JNICALL Java_org_apach
     _sslengine *sslengine = jlong2addr(_sslengine, jsslengine);
     BIO *bio = sslengine->bio;
     BIO *bio_io = sslengine->bio_io;
-    SSL *ssl = NULL;
-    int write_result = 0, read_result = 0;
+    SSL *ssl = jlong2addr(SSL, jssl);
+    int write_result = 0, read_result = 0, shutdownState = 0;
     jobject handshake_state = NULL, engine_state = NULL, result = NULL;
     jclass result_class;
     jmethodID result_constructor;
@@ -207,7 +212,6 @@ JNIEXPORT jobject JNICALL Java_org_apach
     jbyte *dst_buffer = jlong2addr(jbyte, dst_address);
     int initial_init_state, init_state;
 
-    BIO_get_ssl(bio, &ssl);
     initial_init_state = SSL_in_init(ssl);
     
     // write input data
@@ -218,11 +222,7 @@ JNIEXPORT jobject JNICALL Java_org_apach
     }
     
     // read output data
-    //read_result = BIO_read(bio, dst_buffer, dst_len);
-    read_result = SSL_read(ssl, dst_buffer, dst_len);
-    
-    // TODO: Check for  SSL_RECEIVED_SHUTDOWN
-
+    read_result = BIO_read(bio, dst_buffer, dst_len);
     if (read_result > 0) {
         // wrote some data so must not be handshaking
         handshake_state = handshake_not_handshaking;
@@ -236,6 +236,12 @@ JNIEXPORT jobject JNICALL Java_org_apach
         handshake_state = handshake_need_wrap;
         engine_state = engine_ok;
     }
+
+    // Check if close_notify has been sent or received
+    shutdownState = SSL_get_shutdown(ssl);
+    if (shutdownState) {
+        engine_state = engine_closed;
+    }
     
     init_state = SSL_in_init(ssl);
     // if not in SSL init state

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.h?rev=999967&r1=999966&r2=999967&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.h
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslEngine.h
Wed Sep 22 14:20:04 2010
@@ -32,7 +32,7 @@ JNIEXPORT jobject JNICALL Java_org_apach
 JNIEXPORT jobject JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLEngineImpl_connectImpl
   (JNIEnv *, jclass, jlong);
 JNIEXPORT jobject JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLEngineImpl_wrapImpl
-  (JNIEnv *, jclass, jlong, jlong, int, jlong, int);
+  (JNIEnv *, jclass, jlong, jlong, jlong, int, jlong, int);
 JNIEXPORT jobject JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLEngineImpl_unwrapImpl
   (JNIEnv *, jclass, jlong, jlong, jlong, int, jlong, int);
 JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLEngineImpl_shutdownImpl



Mime
View raw message