diff options
author | Elliott Hughes <enh@google.com> | 2011-05-03 10:55:35 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-05-03 10:55:35 -0700 |
commit | e30b5b55806b31d1a61e2885b854dd7b8da1a07a (patch) | |
tree | d6f777c3a839b7a816782d46a50245854e5f2330 /src/org/apache/http/impl/io/SocketOutputBuffer.java | |
parent | 403f11d92b25f7c3060b1a973d4076c5d6585ccf (diff) | |
download | external_apache-http-e30b5b55806b31d1a61e2885b854dd7b8da1a07a.zip external_apache-http-e30b5b55806b31d1a61e2885b854dd7b8da1a07a.tar.gz external_apache-http-e30b5b55806b31d1a61e2885b854dd7b8da1a07a.tar.bz2 |
Make Apache HttpClient play nice with large kernel socket buffers.
Given the large maximum size likely to be set for kernel socket buffers on LTE
devices, we need to stop Apache HttpClient from allocating some integer
multiple of that size on the heap for each socket. On one device, 16 HTTP
connections would fill the heap.
Bug: 3514259
Change-Id: I888c03b6ad4b7ca444c2c423b097a3f76390846b
Diffstat (limited to 'src/org/apache/http/impl/io/SocketOutputBuffer.java')
-rw-r--r-- | src/org/apache/http/impl/io/SocketOutputBuffer.java | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/org/apache/http/impl/io/SocketOutputBuffer.java b/src/org/apache/http/impl/io/SocketOutputBuffer.java index efb91e9..c1d3b49 100644 --- a/src/org/apache/http/impl/io/SocketOutputBuffer.java +++ b/src/org/apache/http/impl/io/SocketOutputBuffer.java @@ -43,37 +43,26 @@ import org.apache.http.params.HttpParams; * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a> * * @version $Revision: 560358 $ - * + * * @since 4.0 */ public class SocketOutputBuffer extends AbstractSessionOutputBuffer { public SocketOutputBuffer( - final Socket socket, + final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } - if (buffersize < 0) { - buffersize = socket.getReceiveBufferSize(); -// BEGIN android-changed - // Workaround for http://b/issue?id=1083103. - if (buffersize > 8096) { - buffersize = 8096; - } -// END android-changed - } - if (buffersize < 1024) { - buffersize = 1024; - } - -// BEGIN android-changed - socket.setSendBufferSize(buffersize * 3); -// END andrdoid-changed - - init(socket.getOutputStream(), buffersize, params); + // BEGIN android-changed + // Workaround for http://b/1083103 and http://b/3514259. We take + // 'buffersize' as a hint in the weakest sense, and always use + // an 8KiB heap buffer and leave the kernel buffer size alone, + // trusting the system to have set a network-appropriate default. + init(socket.getOutputStream(), 8192, params); + // END android-changed } - + } |