Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion drivers/syslog/syslog_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,43 @@
* Private Functions
****************************************************************************/

/****************************************************************************
* Name: syslog_safe_to_block
*
* Description:
* Check if it is safe to block for write. If not, the write defaults to a
* non-blocking method.
*
* Input Parameters:
* None.
*
* Returned Value:
* true if it is safe to block; false otherwise.
*
****************************************************************************/

static bool syslog_safe_to_block(void)
{
FAR const struct tcb_s *rtcb;

/* It's not safe to block in interrupts or when executing the idle loop */

if (up_interrupt_context() || sched_idletask())
{
return false;
}

/* It's not safe to block if a signal is being delivered */

rtcb = nxsched_self();
if (rtcb->sigdeliver != NULL)
{
return false;
}

return true;
}

/****************************************************************************
* Name: syslog_default_write
*
Expand All @@ -59,7 +96,7 @@ static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
{
size_t nwritten;

if (up_interrupt_context() || sched_idletask())
if (!syslog_safe_to_block())
{
#ifdef CONFIG_SYSLOG_INTBUFFER
if (up_interrupt_context())
Expand Down