Skip to content

Commit

Permalink
logging: Fix synchronous logging in thread context
Browse files Browse the repository at this point in the history
Due to flipped logic is_irq_locked function was returning true then
interrupts were unlocked. Because of that CONFIG_LOG_BLOCK_IN_THREAD
feature was not working correctly and wasn't locking thread context
when log message buffer pool was empty.

Signed-off-by: Krzysztof Chruscinski <[email protected]>
  • Loading branch information
nordic-krch authored and nashif committed Dec 19, 2019
1 parent 2c429ca commit 08a017a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions subsys/logging/log_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void log_msg_pool_init(void)
k_mem_slab_init(&log_msg_pool, log_msg_pool_buf, MSG_SIZE, NUM_OF_MSGS);
}

/* Return true if interrupts were locked in the context of this call. */
static bool is_irq_locked(void)
/* Return true if interrupts were unlocked in the context of this call. */
static bool is_irq_unlocked(void)
{
unsigned int key = arch_irq_lock();
bool ret = arch_irq_unlocked(key);
Expand All @@ -68,7 +68,7 @@ static bool block_on_alloc(void)
return false;
}

return (!k_is_in_isr() && !is_irq_locked());
return (!k_is_in_isr() && is_irq_unlocked());
}

union log_msg_chunk *log_msg_chunk_alloc(void)
Expand Down

0 comments on commit 08a017a

Please sign in to comment.