Skip to content

Commit

Permalink
Revert "SYSLOG_DEFAULT: wrap up_putc/up_nputs calls with critical sec…
Browse files Browse the repository at this point in the history
…tion"

This reverts commit f2aeb5e.

Because regressions are reported:
* apache#14722 (comment)
* apache#14722 (comment)
* apache#14749
  • Loading branch information
yamt committed Nov 13, 2024
1 parent 1d1ef52 commit 74bc7fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions drivers/serial/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock)
{
/* The following steps must be atomic with respect to serial
* interrupt handling.
*
* This critical section is also used for the serialization
* with the up_putc-based syslog channels.
* See https://github.com/apache/nuttx/issues/14662
*/

flags = enter_critical_section();
Expand Down
23 changes: 10 additions & 13 deletions drivers/syslog/syslog_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <nuttx/syslog/syslog.h>
#include <nuttx/compiler.h>
#include <nuttx/mutex.h>

#ifdef CONFIG_RAMLOG_SYSLOG
# include <nuttx/syslog/ramlog.h>
Expand Down Expand Up @@ -71,6 +72,10 @@ static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
* Private Data
****************************************************************************/

#if defined(CONFIG_SYSLOG_DEFAULT) && defined(CONFIG_ARCH_LOWPUTC)
static mutex_t g_lowputs_lock = NXMUTEX_INITIALIZER;
#endif

#ifdef CONFIG_RAMLOG_SYSLOG
static const struct syslog_channel_ops_s g_ramlog_channel_ops =
{
Expand Down Expand Up @@ -229,31 +234,23 @@ g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
#ifdef CONFIG_SYSLOG_DEFAULT
static int syslog_default_putc(FAR syslog_channel_t *channel, int ch)
{
# ifdef CONFIG_ARCH_LOWPUTC
/* See https://github.com/apache/nuttx/issues/14662
* about what this critical section is for.
*/
UNUSED(channel);

irqstate_t flags = enter_critical_section();
# ifdef CONFIG_ARCH_LOWPUTC
up_putc(ch);
leave_critical_section(flags);
# endif

UNUSED(channel);
return ch;
}

static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen)
{
# ifdef CONFIG_ARCH_LOWPUTC
/* See https://github.com/apache/nuttx/issues/14662
* about what this critical section is for.
*/
nxmutex_lock(&g_lowputs_lock);

irqstate_t flags = enter_critical_section();
up_nputs(buffer, buflen);
leave_critical_section(flags);

nxmutex_unlock(&g_lowputs_lock);
# endif

UNUSED(channel);
Expand Down

0 comments on commit 74bc7fa

Please sign in to comment.