mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
syslog_inbuffer:Fixed the lock reentry issue in single core + spinlock scenario
Summary: When spinlock.h is enabled in a single-core scenario, spinlock reentry and exceptions may occur when spin_lock_irqsave_wo_note is used in syslog_add_intbuffer Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
@@ -104,8 +104,6 @@ static void syslog_flush_internal(bool force, size_t buflen)
|
||||
* concurrent modification by other tasks.
|
||||
*/
|
||||
|
||||
flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock);
|
||||
|
||||
do
|
||||
{
|
||||
buffer = circbuf_get_readptr(&g_syslog_intbuffer.circ, &size);
|
||||
@@ -118,8 +116,6 @@ static void syslog_flush_internal(bool force, size_t buflen)
|
||||
}
|
||||
}
|
||||
while (size > 0 && buflen > 0);
|
||||
|
||||
spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -201,7 +197,11 @@ void syslog_add_intbuffer(FAR const char *buffer, size_t buflen)
|
||||
|
||||
void syslog_flush_intbuffer(bool force)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock);
|
||||
syslog_flush_internal(force, sizeof(g_syslog_intbuffer.buffer));
|
||||
spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SYSLOG_INTBUFFER */
|
||||
|
||||
Reference in New Issue
Block a user