summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-05-13 18:51:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-13 18:51:34 -0700
commit8fdb207f4dd38b9bb692968c366be5969627c472 (patch)
tree4d73dd3dc2f1a98be6c86a5a176eea77a798ba29
parent022f425d731baea38065019f4b9f61e1e330aaa4 (diff)
parentd83e6b1cf9330504abce1d2c8700c9b6b43cc5e8 (diff)
downloadexternal_apache-http-8fdb207f4dd38b9bb692968c366be5969627c472.zip
external_apache-http-8fdb207f4dd38b9bb692968c366be5969627c472.tar.gz
external_apache-http-8fdb207f4dd38b9bb692968c366be5969627c472.tar.bz2
Merge "Add Socket tagging for granular data accounting."
-rw-r--r--src/org/apache/http/impl/conn/SingleClientConnManager.java25
-rw-r--r--src/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java25
2 files changed, 50 insertions, 0 deletions
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()) {