You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/28 03:08:49 UTC

(nuttx) 04/04: ramlog:flush should reset the tail of the reader

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

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

commit b29d103ad324e786c60f5b02490cf30818700d3b
Author: dulibo1 <du...@xiaomi.com>
AuthorDate: Mon Mar 25 17:18:45 2024 +0800

    ramlog:flush should reset the tail of the reader
    
    Signed-off-by: dulibo1 <du...@xiaomi.com>
---
 drivers/syslog/ramlog.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c
index 02e9ef0443..c16471edc9 100644
--- a/drivers/syslog/ramlog.c
+++ b/drivers/syslog/ramlog.c
@@ -234,6 +234,21 @@ static void ramlog_pollnotify(FAR struct ramlog_dev_s *priv)
     }
 }
 
+/****************************************************************************
+ * Name: ramlog_flush
+ ****************************************************************************/
+
+static void ramlog_bufferflush(FAR struct ramlog_dev_s *priv)
+{
+  FAR struct ramlog_user_s *upriv;
+
+  priv->rl_header->rl_head = 0;
+  list_for_every_entry(&priv->rl_list, upriv, struct ramlog_user_s, rl_node)
+    {
+      upriv->rl_tail = 0;
+    }
+}
+
 /****************************************************************************
  * Name: ramlog_copybuf
  ****************************************************************************/
@@ -535,7 +550,7 @@ static int ramlog_file_ioctl(FAR struct file *filep, int cmd,
         upriv->rl_threashold = (uint32_t)arg;
         break;
       case BIOC_FLUSH:
-        priv->rl_header->rl_head = 0;
+        ramlog_bufferflush(priv);
         break;
       default:
         ret = -ENOTTY;