debug: watchdog Thread 매 체크마다 로그 기록 (WATCHDOG_CHECK)
watchdog이 실제로 돌고 있는지, 어디서 멈추는지 진단용. 매 5초: WATCHDOG_CHECK silence=Xms connected=true/false interrupt 시: WATCHDOG_THREAD interrupted flag 종료 시: WATCHDOG_THREAD stopped Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -364,12 +364,22 @@ class BleManager private constructor(private val context: Context) {
|
|||||||
debugLogger.info("WATCHDOG_STARTED timeout=${watchdogTimeoutMs}ms")
|
debugLogger.info("WATCHDOG_STARTED timeout=${watchdogTimeoutMs}ms")
|
||||||
|
|
||||||
watchdogJob = Thread({
|
watchdogJob = Thread({
|
||||||
|
debugLogger.info("WATCHDOG_THREAD running")
|
||||||
while (watchdogRunning) {
|
while (watchdogRunning) {
|
||||||
try { Thread.sleep(5000) } catch (_: InterruptedException) { break }
|
try { Thread.sleep(5000) } catch (e: InterruptedException) {
|
||||||
if (!watchdogRunning) break
|
debugLogger.warn("WATCHDOG_THREAD interrupted")
|
||||||
if (!isConnected.value) continue
|
break
|
||||||
|
}
|
||||||
|
if (!watchdogRunning) {
|
||||||
|
debugLogger.info("WATCHDOG_THREAD stopped (flag)")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
val silenceMs = System.currentTimeMillis() - lastRxTimestamp
|
val silenceMs = System.currentTimeMillis() - lastRxTimestamp
|
||||||
|
debugLogger.info("WATCHDOG_CHECK silence=${silenceMs}ms connected=${isConnected.value}")
|
||||||
|
|
||||||
|
if (!isConnected.value) continue
|
||||||
|
|
||||||
if (silenceMs > watchdogTimeoutMs) {
|
if (silenceMs > watchdogTimeoutMs) {
|
||||||
// 직접 로그 기록 (handler 블로킹 무관)
|
// 직접 로그 기록 (handler 블로킹 무관)
|
||||||
debugLogger.error("WATCHDOG_TIMEOUT silence=${silenceMs}ms — forcing reconnect")
|
debugLogger.error("WATCHDOG_TIMEOUT silence=${silenceMs}ms — forcing reconnect")
|
||||||
|
|||||||
Reference in New Issue
Block a user