summaryrefslogtreecommitdiffstats
path: root/x-net
diff options
context:
space:
mode:
authorBob Lee <>2009-04-02 22:19:27 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-02 22:19:27 -0700
commit8d383ffd9c76545e13832c515f7f9e9406bf0eaa (patch)
tree9e4963d57661a921b37bf57fa3682122c2d76f9c /x-net
parent59ac99338810e4fbb3ae3749973dd3ebda2ba2af (diff)
downloadlibcore-8d383ffd9c76545e13832c515f7f9e9406bf0eaa.zip
libcore-8d383ffd9c76545e13832c515f7f9e9406bf0eaa.tar.gz
libcore-8d383ffd9c76545e13832c515f7f9e9406bf0eaa.tar.bz2
AI 144381: am: CL 144356 Synchronized code that touches native SSL sessions.
Original author: crazybob Merged from: //branches/cupcake/... Automated import of CL 144381
Diffstat (limited to 'x-net')
-rw-r--r--x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java4
-rw-r--r--x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java21
2 files changed, 19 insertions, 6 deletions
diff --git a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
index ca7d6f8..b218271 100644
--- a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
+++ b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
@@ -516,6 +516,8 @@ public class OpenSSLSessionImpl implements SSLSession {
* Frees the OpenSSL session in the memory.
*/
protected void finalize() {
- nativefree(session);
+ synchronized (OpenSSLSocketImpl.class) {
+ nativefree(session);
+ }
}
}
diff --git a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
index 8779736..3b9006d 100644
--- a/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
+++ b/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
@@ -303,8 +303,12 @@ public class OpenSSLSocketImpl extends javax.net.ssl.SSLSocket {
} else {
Socket socket = this.socket != null ? this.socket : this;
int sessionId = session != null ? session.session : 0;
- if (nativeconnect(ssl_ctx, socket, sslParameters.getUseClientMode(),
- sessionId)) {
+ boolean reusedSession;
+ synchronized (OpenSSLSocketImpl.class) {
+ reusedSession = nativeconnect(ssl_ctx, socket,
+ sslParameters.getUseClientMode(), sessionId);
+ }
+ if (reusedSession) {
// nativeconnect shouldn't return true if the session is not
// done
session.lastAccessedTime = System.currentTimeMillis();
@@ -323,14 +327,17 @@ public class OpenSSLSocketImpl extends javax.net.ssl.SSLSocket {
ClientSessionContext sessionContext
= sslParameters.getClientSessionContext();
+ synchronized (OpenSSLSocketImpl.class) {
+ sessionId = nativegetsslsession(ssl);
+ }
if (address == null) {
sslSession = new OpenSSLSessionImpl(
- nativegetsslsession(ssl), sslParameters,
+ sessionId, sslParameters,
super.getInetAddress().getHostName(),
super.getPort(), sessionContext);
} else {
sslSession = new OpenSSLSessionImpl(
- nativegetsslsession(ssl), sslParameters,
+ sessionId, sslParameters,
address.getHostName(), address.getPort(),
sessionContext);
}
@@ -344,9 +351,13 @@ public class OpenSSLSocketImpl extends javax.net.ssl.SSLSocket {
throw new SSLException("Server sends no certificate");
}
+ String authMethod;
+ synchronized (OpenSSLSocketImpl.class) {
+ authMethod = nativecipherauthenticationmethod();
+ }
sslParameters.getTrustManager().checkServerTrusted(
peerCertificates,
- nativecipherauthenticationmethod());
+ authMethod);
sessionContext.putSession(sslSession);
} catch (CertificateException e) {
throw new SSLException("Not trusted server certificate", e);