summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2011-04-21 13:44:30 -0700
committerJeff Sharkey <jsharkey@android.com>2011-05-13 16:57:32 -0700
commitd83e6b1cf9330504abce1d2c8700c9b6b43cc5e8 (patch)
tree893c676d0c74f2e4a20b544e6a6489e1f3b77a5b /src
parent81d5133bb7843bc65c5321e53f5017ce2e4d13af (diff)
downloadexternal_apache-http-d83e6b1cf9330504abce1d2c8700c9b6b43cc5e8.zip
external_apache-http-d83e6b1cf9330504abce1d2c8700c9b6b43cc5e8.tar.gz
external_apache-http-d83e6b1cf9330504abce1d2c8700c9b6b43cc5e8.tar.bz2
Add Socket tagging for granular data accounting.
Changes SingleClientConnManager and ThreadSafeClientConnManager to tag any recycled Sockets based on the current thread. (Actual tagging is maintained and applied in BlockGuard.) Change-Id: Ib34897bb2af8641fa65adc664f7858f9d43ffeeb
Diffstat (limited to 'src')
-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()) {