You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2024/04/21 09:40:07 UTC

(nuttx) 01/02: drivers: syslog: Replace sched_lock with critical section in syslog_flush_intbuffer()

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 72548951d374620792a3d80396de349702362e9d
Author: hujun5 <hu...@xiaomi.com>
AuthorDate: Thu Apr 18 21:19:35 2024 +0800

    drivers: syslog: Replace sched_lock with critical section in syslog_flush_intbuffer()
    
    Signed-off-by: hujun5 <hu...@xiaomi.com>
---
 drivers/syslog/syslog_intbuffer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/syslog/syslog_intbuffer.c b/drivers/syslog/syslog_intbuffer.c
index 6347e179f0..cdff96df3a 100644
--- a/drivers/syslog/syslog_intbuffer.c
+++ b/drivers/syslog/syslog_intbuffer.c
@@ -249,6 +249,7 @@ int syslog_add_intbuffer(int ch)
 int syslog_flush_intbuffer(bool force)
 {
   syslog_putc_t putfunc;
+  irqstate_t flags;
   int ch;
   int i;
 
@@ -256,7 +257,7 @@ int syslog_flush_intbuffer(bool force)
    * concurrent modification by other tasks.
    */
 
-  sched_lock();
+  flags = enter_critical_section();
 
   do
     {
@@ -293,7 +294,7 @@ int syslog_flush_intbuffer(bool force)
     }
   while (ch != EOF);
 
-  sched_unlock();
+  leave_critical_section(flags);
 
   return ch;
 }