android: close TCP probe sockets right after connecting
tcpPing never closed its socket: every health/whitelist/home probe leaked an fd until GC and the peer's later FIN/RST woke the radio again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
793ca1b410
commit
2b40eebf5b
1 file changed
+6
-2
+6
-2
@@ -94,8 +94,12 @@ object ConnectivityProbe
|
|||||||
* throw (e.g. EPERM when the caller is disallowed from that
|
* throw (e.g. EPERM when the caller is disallowed from that
|
||||||
* network), so it must stay inside the try */
|
* network), so it must stay inside the try */
|
||||||
val socket = if (network != null) network.socketFactory.createSocket() else Socket()
|
val socket = if (network != null) network.socketFactory.createSocket() else Socket()
|
||||||
socket.tcpNoDelay = true
|
/* close right away: a leaked socket holds an fd until GC and
|
||||||
socket.connect(InetSocketAddress(host, port), timeoutMs)
|
* the peer's later FIN/RST wakes the radio a second time */
|
||||||
|
socket.use {
|
||||||
|
it.tcpNoDelay = true
|
||||||
|
it.connect(InetSocketAddress(host, port), timeoutMs)
|
||||||
|
}
|
||||||
ProbeResult(target = target, ok = true, rttMs = (System.nanoTime() - started) / 1_000_000)
|
ProbeResult(target = target, ok = true, rttMs = (System.nanoTime() - started) / 1_000_000)
|
||||||
}
|
}
|
||||||
catch (_: Exception)
|
catch (_: Exception)
|
||||||
|
|||||||
Reference in new issue
Block a user