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 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-10-10 09:09:39 +07:00
1 parent 793ca1b410
commit 2b40eebf5b
1 file changed
+6 -2
@@ -94,8 +94,12 @@ object ConnectivityProbe
* throw (e.g. EPERM when the caller is disallowed from that
* network), so it must stay inside the try */
val socket = if (network != null) network.socketFactory.createSocket() else Socket()
socket.tcpNoDelay = true
socket.connect(InetSocketAddress(host, port), timeoutMs)
/* close right away: a leaked socket holds an fd until GC and
* 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)
}
catch (_: Exception)