diff options
3 files changed, 51 insertions, 1 deletions
diff --git a/src/org/apache/http/conn/ssl/AbstractVerifier.java b/src/org/apache/http/conn/ssl/AbstractVerifier.java index e409db9..723d806 100644 --- a/src/org/apache/http/conn/ssl/AbstractVerifier.java +++ b/src/org/apache/http/conn/ssl/AbstractVerifier.java @@ -163,7 +163,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier { // action. It also can't be [*.co.uk] or [*.co.jp] or // [*.org.uk], etc... boolean doWildcard = cn.startsWith("*.") && - cn.lastIndexOf('.') >= 0 && + cn.indexOf('.', 2) != -1 && acceptableCountryWildcard(cn) && !InetAddressUtils.isIPv4Address(host); diff --git a/src/org/apache/http/impl/conn/SingleClientConnManager.java b/src/org/apache/http/impl/conn/SingleClientConnManager.java index 7999f3e..d770a35 100644 --- a/src/org/apache/http/impl/conn/SingleClientConnManager.java +++ b/src/org/apache/http/impl/conn/SingleClientConnManager.java @@ -31,7 +31,10 @@ package org.apache.http.impl.conn; +import dalvik.system.BlockGuard; + import java.io.IOException; +import java.net.Socket; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; @@ -249,6 +252,19 @@ public class SingleClientConnManager implements ClientConnectionManager { if (recreate) uniquePoolEntry = new PoolEntry(); + // BEGIN android-changed + // When using a recycled Socket, we need to re-tag it with any + // updated statistics options. + try { + final Socket socket = uniquePoolEntry.connection.getSocket(); + if (socket != null) { + BlockGuard.tagSocketFd(socket.getFileDescriptor$()); + } + } catch (IOException iox) { + log.debug("Problem tagging socket.", iox); + } + // END android-changed + managedConn = new ConnAdapter(uniquePoolEntry, route); return managedConn; @@ -279,6 +295,15 @@ public class SingleClientConnManager implements ClientConnectionManager { } try { + // BEGIN android-changed + // When recycling a Socket, we un-tag it to avoid collecting + // statistics from future users. + final Socket socket = uniquePoolEntry.connection.getSocket(); + if (socket != null) { + BlockGuard.untagSocketFd(socket.getFileDescriptor$()); + } + // END android-changed + // make sure that the response has been read completely if (sca.isOpen() && (this.alwaysShutDown || !sca.isMarkedReusable()) diff --git a/src/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/src/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java index 0781e05..717acf0 100644 --- a/src/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java +++ b/src/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java @@ -30,7 +30,10 @@ package org.apache.http.impl.conn.tsccm; +import dalvik.system.BlockGuard; + import java.io.IOException; +import java.net.Socket; import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; @@ -173,6 +176,18 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager { } BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit); + // BEGIN android-changed + // When using a recycled Socket, we need to re-tag it with any + // updated statistics options. + try { + final Socket socket = entry.getConnection().getSocket(); + if (socket != null) { + BlockGuard.tagSocketFd(socket.getFileDescriptor$()); + } + } catch (IOException iox) { + log.debug("Problem tagging socket.", iox); + } + // END android-changed return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry); } @@ -196,6 +211,16 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager { } try { + // BEGIN android-changed + // When recycling a Socket, we un-tag it to avoid collecting + // statistics from future users. + final BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry(); + final Socket socket = entry.getConnection().getSocket(); + if (socket != null) { + BlockGuard.untagSocketFd(socket.getFileDescriptor$()); + } + // END android-changed + // make sure that the response has been read completely if (hca.isOpen() && !hca.isMarkedReusable()) { if (log.isDebugEnabled()) { |