This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 393b2a2da8dee7e576bdcd5b06ab79f574c25a11 Author: yinshengkai <[email protected]> AuthorDate: Thu Mar 27 18:09:26 2025 +0800 drivers/syslog: flush the whole interrupt buffer when a message does not fit When a message did not fit in the space left in the interrupt buffer, syslog_add_intbuffer() flushed just enough of the older data to make room for it, or, for a message larger than the whole buffer, wrote the head of the message out directly and kept its tail in the buffer. Flush the whole buffer and write the new message straight out instead. The output keeps its order, and a message is no longer split between a direct write and the buffer. Signed-off-by: yinshengkai <[email protected]> --- drivers/syslog/syslog_intbuffer.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/syslog/syslog_intbuffer.c b/drivers/syslog/syslog_intbuffer.c index b6beb3a0387..b54e8017556 100644 --- a/drivers/syslog/syslog_intbuffer.c +++ b/drivers/syslog/syslog_intbuffer.c @@ -158,18 +158,10 @@ void syslog_add_intbuffer(FAR const char *buffer, size_t buflen) { circbuf_write(&g_syslog_intbuffer.circ, buffer, buflen); } - else if (buflen <= sizeof(g_syslog_intbuffer.buffer)) - { - syslog_flush_internal(true, buflen - space); - circbuf_write(&g_syslog_intbuffer.circ, buffer, buflen); - } else { syslog_flush_internal(true, sizeof(g_syslog_intbuffer.buffer)); - space = buflen - sizeof(g_syslog_intbuffer.buffer); - syslog_write_foreach(SYSLOG_PRIORITY_NONE, buffer, space, true); - circbuf_write(&g_syslog_intbuffer.circ, - buffer + space, buflen - space); + syslog_write_foreach(SYSLOG_PRIORITY_NONE, buffer, buflen, true); } spin_unlock_irqrestore_notrace(&g_syslog_intbuffer.splock, flags);
