fix: ping as engine instance method — same lifecycle as call
Ping was a static JNI method that loaded the .so before nativeInit, crashing jemalloc. Now ping is an instance method on WzpEngine: - Engine is created once (nativeInit), reused for both ping and call - pingRelay() uses same tokio runtime pattern as startCall() - Auto-pings all servers on app launch (after engine init) - No process restart needed - TOFU fingerprints saved on first successful ping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,36 +1,12 @@
|
||||
package com.wzp.net
|
||||
|
||||
/**
|
||||
* Relay ping via native QUIC — requires loading the native .so.
|
||||
* After ping completes, the process must be restarted (System.exit)
|
||||
* because jemalloc initialization during .so load corrupts state
|
||||
* on Android 16 MTE devices.
|
||||
*
|
||||
* Flow: ping all servers → save results → exit → app restarts → load results
|
||||
*/
|
||||
object RelayPinger {
|
||||
// Relay pinging is now done via WzpEngine.pingRelay() (instance method).
|
||||
// This file kept for the data class only.
|
||||
|
||||
object RelayPinger {
|
||||
data class PingResult(
|
||||
val rttMs: Int,
|
||||
val reachable: Boolean,
|
||||
val serverFingerprint: String = "",
|
||||
)
|
||||
|
||||
/**
|
||||
* Ping a relay via the native QUIC stack.
|
||||
* WARNING: After calling this, the process must be restarted.
|
||||
*/
|
||||
fun ping(address: String): PingResult {
|
||||
return try {
|
||||
val json = com.wzp.engine.WzpEngine.pingRelay(address) ?: return PingResult(0, false)
|
||||
val obj = org.json.JSONObject(json)
|
||||
PingResult(
|
||||
rttMs = obj.getInt("rtt_ms"),
|
||||
reachable = true,
|
||||
serverFingerprint = obj.optString("server_fingerprint", ""),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
PingResult(0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user