-
Notifications
You must be signed in to change notification settings - Fork 8k
subsys: logging: log_core: correct timeout of -1 ms to K_FOREVER #63958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subsys: logging: log_core: correct timeout of -1 ms to K_FOREVER #63958
Conversation
1021133
to
440b747
Compare
Many releases ago, specifying to block indefinitely in the log processing thread would do just that. However, a subtle bug was introduced such that specifying -1 for `CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS` would have the exact opposite effect than what was intended. As per Kconfig, a value of -1 should translate to a timeout of `K_FOREVER`. However, conversion via `K_MSEC(-1)` results in a `k_timeout_t` that is equal to `K_NO_WAIT` rather than the intent which is `K_FOREVER`. Add a dedicated check to to ensure that a value of -1 is correctly interpreted as `K_FOREVER` in `log_core.c`. For reference, the blocking feature was described in zephyrproject-rtos#15196, added in zephyrproject-rtos#16194, and it would appear that the regression happened in c5f2cde. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
440b747
to
6fc1d5a
Compare
Assertions that can demonstrate the issue above __ASSERT_NO_MSG(K_TIMEOUT_EQ(K_NO_WAIT, K_MSEC(-1)));
__ASSERT_NO_MSG(!K_TIMEOUT_EQ(K_FOREVER, K_MSEC(-1))); |
K_MSEC(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS)); | ||
return (struct log_msg *)mpsc_pbuf_alloc( | ||
buffer, wlen, | ||
(CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A future enhancement would be to generalize this for any timeout value < 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
Shouldn't this be backported? |
Many releases ago, specifying to block indefinitely in the log processing thread would do just that.
However, a subtle bug was introduced such that specifying -1 for
CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS
would have the exact opposite effect than what was intended.As per Kconfig, a value of -1 should translate to a timeout of
K_FOREVER
. However, conversion viaK_MSEC(-1)
results in ak_timeout_t
that is equal toK_NO_WAIT
.Add a dedicated check to to ensure that a value of -1 is correctly interpreted as
K_FOREVER
inlog_core.c
.For reference, the blocking feature was described in #15196, added in #16194, and it would appear that the regression happened in c5f2cde.
Fixes #63965