diff options
author | Brian Carlstrom <bdc@google.com> | 2013-09-10 19:41:12 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-09-10 19:41:12 +0000 |
commit | 1187fa467f76dacb1a169075074aace25f990899 (patch) | |
tree | f52353e98006b7e5f8e853ff47e1db169be6984a | |
parent | 0d819a82fbf9b719e5892ad1e3163518705e3eb1 (diff) | |
parent | 36f1c15a1cb2e66b8852ea51f7a82c4ccc9ac886 (diff) | |
download | libcore-1187fa467f76dacb1a169075074aace25f990899.zip libcore-1187fa467f76dacb1a169075074aace25f990899.tar.gz libcore-1187fa467f76dacb1a169075074aace25f990899.tar.bz2 |
Merge "Fixed interruption of blocked SSLSocket via Socket.close()"
-rw-r--r-- | NativeCode.mk | 15 | ||||
-rw-r--r-- | luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java | 55 |
2 files changed, 30 insertions, 40 deletions
diff --git a/NativeCode.mk b/NativeCode.mk index 42319dc..1a47ee4 100644 --- a/NativeCode.mk +++ b/NativeCode.mk @@ -95,11 +95,10 @@ LOCAL_CFLAGS += $(core_cflags) LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" LOCAL_CPPFLAGS += $(core_cppflags) LOCAL_SRC_FILES := \ - crypto/src/main/native/org_conscrypt_NativeCrypto.cpp \ - luni/src/main/native/AsynchronousSocketCloseMonitor.cpp + crypto/src/main/native/org_conscrypt_NativeCrypto.cpp LOCAL_C_INCLUDES += $(core_c_includes) \ libcore/luni/src/main/native -LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libssl libnativehelper libz +LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libcrypto libssl libnativehelper libz libjavacore LOCAL_STATIC_LIBRARIES += $(core_static_libraries) LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libjavacrypto @@ -146,8 +145,7 @@ ifeq ($(WITH_HOST_DALVIK),true) # Conscrypt native library for host include $(CLEAR_VARS) LOCAL_SRC_FILES += \ - crypto/src/main/native/org_conscrypt_NativeCrypto.cpp \ - luni/src/main/native/AsynchronousSocketCloseMonitor.cpp + crypto/src/main/native/org_conscrypt_NativeCrypto.cpp LOCAL_C_INCLUDES += $(core_c_includes) \ libcore/luni/src/main/native LOCAL_CPPFLAGS += $(core_cppflags) @@ -156,15 +154,14 @@ ifeq ($(WITH_HOST_DALVIK),true) LOCAL_MODULE := libjavacrypto LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk - LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libssl-host libcrypto-host + LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libssl-host libcrypto-host libjavacore LOCAL_STATIC_LIBRARIES += $(core_static_libraries) include $(BUILD_HOST_SHARED_LIBRARY) # Conscrypt native library for nojarjar'd version include $(CLEAR_VARS) LOCAL_SRC_FILES += \ - crypto/src/main/native/org_conscrypt_NativeCrypto.cpp \ - luni/src/main/native/AsynchronousSocketCloseMonitor.cpp + crypto/src/main/native/org_conscrypt_NativeCrypto.cpp LOCAL_C_INCLUDES += $(core_c_includes) \ libcore/luni/src/main/native LOCAL_CPPFLAGS += $(core_cppflags) @@ -172,7 +169,7 @@ ifeq ($(WITH_HOST_DALVIK),true) LOCAL_MODULE_TAGS := optional LOCAL_MODULE := libconscrypt_jni LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/NativeCode.mk - LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libssl-host libcrypto-host + LOCAL_SHARED_LIBRARIES += $(core_shared_libraries) libssl-host libcrypto-host libjavacore LOCAL_STATIC_LIBRARIES += $(core_static_libraries) include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java index 04b81b0..dd56529 100644 --- a/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java +++ b/luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java @@ -1239,40 +1239,29 @@ public class SSLSocketTest extends TestCase { } public void test_SSLSocket_interrupt() throws Exception { - ServerSocket listening = new ServerSocket(0); - - for (int i = 0; i < 3; i++) { - Socket underlying = new Socket(listening.getInetAddress(), listening.getLocalPort()); - Socket server = listening.accept(); - - SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault(); - Socket clientWrapping = sf.createSocket(underlying, null, -1, true); - - switch (i) { - case 0: - test_SSLSocket_interrupt_case(underlying, underlying); - break; - case 1: - test_SSLSocket_interrupt_case(underlying, clientWrapping); - break; - case 2: - test_SSLSocket_interrupt_case(clientWrapping, underlying); - break; - case 3: - test_SSLSocket_interrupt_case(clientWrapping, clientWrapping); - break; - default: - fail(); - } - - server.close(); - underlying.close(); + test_SSLSocket_interrupt_case(true, true); + test_SSLSocket_interrupt_case(true, false); + test_SSLSocket_interrupt_case(false, true); + // Currently failing due to reader blocking closing thread http://b/10681815 + if (StandardNames.IS_RI) { + test_SSLSocket_interrupt_case(false, false); } - listening.close(); } - private void test_SSLSocket_interrupt_case(Socket toRead, final Socket toClose) + private void test_SSLSocket_interrupt_case(boolean readUnderlying, boolean closeUnderlying) throws Exception { + + ServerSocket listening = new ServerSocket(0); + + Socket underlying = new Socket(listening.getInetAddress(), listening.getLocalPort()); + Socket server = listening.accept(); + + SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault(); + Socket clientWrapping = sf.createSocket(underlying, null, -1, true); + + final Socket toRead = (readUnderlying) ? underlying : clientWrapping; + final Socket toClose = (closeUnderlying) ? underlying : clientWrapping; + ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Void> future = executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { @@ -1283,7 +1272,7 @@ public class SSLSocketTest extends TestCase { }); executor.shutdown(); try { - toRead.setSoTimeout(10 * 1000); + toRead.setSoTimeout(5 * 1000); toRead.getInputStream().read(); fail(); } catch (SocketTimeoutException e) { @@ -1291,6 +1280,10 @@ public class SSLSocketTest extends TestCase { } catch (SocketException expected) { } future.get(); + + server.close(); + underlying.close(); + listening.close(); } /** |