Skip to content

Commit 16f5880

Browse files
committed
logging: fix bug where links wouldn't be promptly activated
The log process thread is what activates multidomain log links, but if all backends were already initialized, it would enter a mode where it would block until new local logs were ready to be processed, even if links were not yet completed in activation. Change the logic for computing the timeout used to block the processing thread so that it stays in periodic polling mode if there are still log links that haven't finished activating. Signed-off-by: Mike J. Chen <[email protected]>
1 parent 53c79c6 commit 16f5880

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

subsys/logging/log_core.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,19 @@ static void log_process_thread_func(void *dummy1, void *dummy2, void *dummy3)
940940
uint32_t links_active_mask = 0xFFFFFFFF;
941941
uint8_t domain_offset = 0;
942942
uint32_t activate_mask = z_log_init(false, false);
943-
/* If some backends are not activated yet set periodical thread wake up
944-
* to poll backends for readiness. Period is set arbitrary.
945-
* If all backends are ready periodic wake up is not needed.
946-
*/
947-
k_timeout_t timeout = (activate_mask != 0) ? K_MSEC(50) : K_FOREVER;
943+
k_timeout_t timeout;
944+
if (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN)) {
945+
/* when multidomain is enabled, start in periodic polling
946+
* mode to check for link readiness
947+
*/
948+
timeout = K_MSEC(50);
949+
} else {
950+
/* If some backends are not activated yet set periodical thread wake up
951+
* to poll backends for readiness. Period is set arbitrary.
952+
* If all backends are ready periodic wake up is not needed.
953+
*/
954+
timeout = (activate_mask != 0) ? K_MSEC(50) : K_FOREVER;
955+
}
948956
bool processed_any = false;
949957
thread_set(k_current_get());
950958

@@ -955,17 +963,32 @@ static void log_process_thread_func(void *dummy1, void *dummy2, void *dummy3)
955963
if (activate_mask) {
956964
activate_mask = activate_foreach_backend(activate_mask);
957965
if (!activate_mask) {
958-
/* Periodic wake up no longer needed since all
959-
* backends are ready.
960-
*/
961-
timeout = K_FOREVER;
966+
if (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN)) {
967+
if (!links_active_mask) {
968+
/* Periodic wake up no longer needed since all
969+
* backends and links are ready.
970+
*/
971+
timeout = K_FOREVER;
972+
}
973+
} else {
974+
/* Periodic wake up no longer needed since all
975+
* backends are ready.
976+
*/
977+
timeout = K_FOREVER;
978+
}
962979
}
963980
}
964981

965982
/* Keep trying to activate links until all links are active. */
966983
if (IS_ENABLED(CONFIG_LOG_MULTIDOMAIN) && links_active_mask) {
967984
links_active_mask =
968985
z_log_links_activate(links_active_mask, &domain_offset);
986+
if (!links_active_mask && !activate_mask) {
987+
/* Periodic wake up no longer needed since all
988+
* backends and links are ready.
989+
*/
990+
timeout = K_FOREVER;
991+
}
969992
}
970993

971994

0 commit comments

Comments
 (0)