From 5c2d9a2a4f1781726f04daf09aefc7a24790d7d5 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Thu, 5 Aug 2021 12:18:54 -0400 Subject: [PATCH] #### Problem The event loop in JNI `IOThreadMain()` used to wait no more than ten seconds on each iteration. This timeout was temporarily removed in PR #6561. #### Change overview Add an explicit ten second timer. Fixes #7756 _add a timer for sleepTime.tv_sec = 10; sleepTime.tv_usec = 0;_ #### Testing Passes Android workflow. --- src/controller/java/CHIPDeviceController-JNI.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 94d4f6d4780a0d..99c765fb401135 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -1066,7 +1066,10 @@ void * IOThreadMain(void * arg) // Loop until we are told to exit. while (!quit.load(std::memory_order_relaxed)) { - // TODO(#5556): add a timer for `sleepTime.tv_sec = 10; sleepTime.tv_usec = 0;` + // Wait no more than 10 seconds. + constexpr uint32_t k10secondsInMilliseconds = 10000; + sSystemLayer.StartTimer(k10secondsInMilliseconds, [](System::Layer *, void *, CHIP_ERROR) -> void {}, nullptr); + watchState.PrepareEvents(); // Unlock the stack so that Java threads can make API calls.