forked from nuttx/nuttx-update
ramlog: workaround the unsafe critical section
thread1: thread2: ramlog_addbuf() enter_critical_section() ramlog_pollnotify() foreach rl_list --> switch out ramlog_file_close enter_critical_section() list_delete() leave_critical_section() <--- switch back rl_list error leave_critical_section() Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
78d93eb628
commit
981bda5cf0
1 changed files with 14 additions and 0 deletions
|
@ -337,6 +337,13 @@ static ssize_t ramlog_addbuf(FAR struct ramlog_dev_s *priv,
|
|||
|
||||
if (len > 0)
|
||||
{
|
||||
/* Lock the scheduler do NOT switch out */
|
||||
|
||||
if (!up_interrupt_context())
|
||||
{
|
||||
sched_lock();
|
||||
}
|
||||
|
||||
#ifndef CONFIG_RAMLOG_NONBLOCKING
|
||||
/* Are there threads waiting for read data? */
|
||||
|
||||
|
@ -345,6 +352,13 @@ static ssize_t ramlog_addbuf(FAR struct ramlog_dev_s *priv,
|
|||
/* Notify all poll/select waiters that they can read from the FIFO */
|
||||
|
||||
ramlog_pollnotify(priv);
|
||||
|
||||
/* Unlock the scheduler */
|
||||
|
||||
if (!up_interrupt_context())
|
||||
{
|
||||
sched_unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* We always have to return the number of bytes requested and NOT the
|
||||
|
|
Loading…
Reference in a new issue