diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2014-07-30 17:17:13 +0900 |
---|---|---|
committer | Paul Jensen <pauljensen@google.com> | 2014-07-30 17:31:04 +0000 |
commit | f0382899c71a540103ba2dbcd0fe8aa8c926c4a8 (patch) | |
tree | 2473a5e45c92155cc776d8cd12fff62909f4fe03 /services/core/java/com/android/server/connectivity/NetworkMonitor.java | |
parent | af4d04cab6d48ae0d6a5e79bd30f679af87abaad (diff) | |
download | frameworks_base-f0382899c71a540103ba2dbcd0fe8aa8c926c4a8.zip frameworks_base-f0382899c71a540103ba2dbcd0fe8aa8c926c4a8.tar.gz frameworks_base-f0382899c71a540103ba2dbcd0fe8aa8c926c4a8.tar.bz2 |
Use a new socket for each of the host's IP addresses.
If Socket.connect() times out, the socket cannot be used any
more - any attempt to do so fails with EBADF. Use a new
socket for each IP address.
Bug: 16664129
Change-Id: If3616df86f7c2da0eabd30dca5db65d0da85cb17
Diffstat (limited to 'services/core/java/com/android/server/connectivity/NetworkMonitor.java')
-rw-r--r-- | services/core/java/com/android/server/connectivity/NetworkMonitor.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/connectivity/NetworkMonitor.java b/services/core/java/com/android/server/connectivity/NetworkMonitor.java index e1c102a..488c09d 100644 --- a/services/core/java/com/android/server/connectivity/NetworkMonitor.java +++ b/services/core/java/com/android/server/connectivity/NetworkMonitor.java @@ -630,12 +630,13 @@ public class NetworkMonitor extends StateMachine { urlConnection.getInputStream(); httpResponseCode = urlConnection.getResponseCode(); } else { - socket = mNetworkAgentInfo.network.getSocketFactory().createSocket(); - socket.setSoTimeout(SOCKET_TIMEOUT_MS); // Lookup addresses only on this Network. InetAddress[] hostAddresses = mNetworkAgentInfo.network.getAllByName(url.getHost()); // Try all addresses. for (int i = 0; i < hostAddresses.length; i++) { + // Create a new socket for every IP address. See http://b/16664129 . + socket = mNetworkAgentInfo.network.getSocketFactory().createSocket(); + socket.setSoTimeout(SOCKET_TIMEOUT_MS); if (DBG) log("Connecting to " + hostAddresses[i]); try { socket.connect(new InetSocketAddress(hostAddresses[i], |