Skip to content

Commit 3b6f463

Browse files
crafcat7xiaoxiang781216
authored andcommitted
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>
1 parent ad71980 commit 3b6f463

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/syslog/syslog_intbuffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ static void syslog_flush_internal(bool force, size_t buflen)
104104
* concurrent modification by other tasks.
105105
*/
106106

107-
flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock);
108-
109107
do
110108
{
111109
buffer = circbuf_get_readptr(&g_syslog_intbuffer.circ, &size);
@@ -118,8 +116,6 @@ static void syslog_flush_internal(bool force, size_t buflen)
118116
}
119117
}
120118
while (size > 0 && buflen > 0);
121-
122-
spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags);
123119
}
124120

125121
/****************************************************************************
@@ -201,7 +197,11 @@ void syslog_add_intbuffer(FAR const char *buffer, size_t buflen)
201197

202198
void syslog_flush_intbuffer(bool force)
203199
{
200+
irqstate_t flags;
201+
202+
flags = spin_lock_irqsave_wo_note(&g_syslog_intbuffer.splock);
204203
syslog_flush_internal(force, sizeof(g_syslog_intbuffer.buffer));
204+
spin_unlock_irqrestore_wo_note(&g_syslog_intbuffer.splock, flags);
205205
}
206206

207207
#endif /* CONFIG_SYSLOG_INTBUFFER */

0 commit comments

Comments
 (0)