drivers/syslog: Ensure interrupt log doesn't interlace in normal log. Don't call syslog_putc in syslog_default_write because syslog_putc will try to empty the interrupt buffer every time.
This commit is contained in:
parent
e3f23b5bca
commit
f579c43754
@ -127,9 +127,6 @@ static int ramlog_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
#ifdef CONFIG_RAMLOG_SYSLOG
|
||||
static const struct syslog_channel_s g_ramlog_syslog_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_default_write,
|
||||
#endif
|
||||
ramlog_putc,
|
||||
ramlog_putc,
|
||||
ramlog_flush
|
||||
|
@ -271,26 +271,6 @@ int syslog_putc(int ch);
|
||||
|
||||
ssize_t syslog_write(FAR const char *buffer, size_t buflen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_default_write
|
||||
*
|
||||
* Description:
|
||||
* This provides a default write method for syslog devices that do not
|
||||
* support multiple byte writes This functions simply loops, outputting
|
||||
* one cahracter at a time.
|
||||
*
|
||||
* Input Parameters:
|
||||
* buffer - The buffer containing the data to be output
|
||||
* buflen - The number of bytes in the buffer
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the number of characters written is returned. A negated
|
||||
* errno value is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t syslog_default_write(FAR const char *buffer, size_t buflen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_force
|
||||
*
|
||||
|
@ -79,9 +79,6 @@ static int syslog_default_flush(void);
|
||||
#if defined(CONFIG_RAMLOG_SYSLOG)
|
||||
const struct syslog_channel_s g_default_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_default_write,
|
||||
#endif
|
||||
ramlog_putc,
|
||||
ramlog_putc,
|
||||
syslog_default_flush
|
||||
@ -89,9 +86,6 @@ const struct syslog_channel_s g_default_channel =
|
||||
#elif defined(HAVE_LOWPUTC)
|
||||
const struct syslog_channel_s g_default_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_default_write,
|
||||
#endif
|
||||
up_putc,
|
||||
up_putc,
|
||||
syslog_default_flush
|
||||
@ -99,9 +93,6 @@ const struct syslog_channel_s g_default_channel =
|
||||
#else
|
||||
const struct syslog_channel_s g_default_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_default_write,
|
||||
#endif
|
||||
syslog_default_putc,
|
||||
syslog_default_putc,
|
||||
syslog_default_flush
|
||||
|
@ -83,9 +83,6 @@ static int syslog_console_force(int ch);
|
||||
|
||||
static const struct syslog_channel_s g_syslog_console_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
syslog_dev_putc,
|
||||
#ifdef HAVE_LOWPUTC
|
||||
up_putc,
|
||||
@ -93,6 +90,9 @@ static const struct syslog_channel_s g_syslog_console_channel =
|
||||
syslog_console_force,
|
||||
#endif
|
||||
syslog_dev_flush,
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -74,9 +74,6 @@ static int syslog_devchan_force(int ch);
|
||||
|
||||
static const struct syslog_channel_s g_syslog_dev_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
#ifdef CONFIG_SYSLOG_CHAR_CRLF
|
||||
syslog_devchan_putc,
|
||||
#else
|
||||
@ -84,6 +81,9 @@ static const struct syslog_channel_s g_syslog_dev_channel =
|
||||
#endif
|
||||
syslog_devchan_force,
|
||||
syslog_dev_flush,
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -72,12 +72,12 @@ static int syslog_file_force(int ch);
|
||||
|
||||
static const struct syslog_channel_s g_syslog_file_channel =
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
syslog_dev_putc,
|
||||
syslog_file_force,
|
||||
syslog_dev_flush,
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_dev_write,
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "syslog.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@ -57,7 +57,7 @@
|
||||
* Description:
|
||||
* This provides a default write method for syslog devices that do not
|
||||
* support multiple byte writes This functions simply loops, outputting
|
||||
* one cahracter at a time.
|
||||
* one character at a time.
|
||||
*
|
||||
* Input Parameters:
|
||||
* buffer - The buffer containing the data to be output
|
||||
@ -69,21 +69,49 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
|
||||
static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
size_t nwritten;
|
||||
int ret;
|
||||
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
if (up_interrupt_context() || sched_idletask())
|
||||
{
|
||||
int ch = *buffer++;
|
||||
ret = syslog_putc(ch);
|
||||
UNUSED(ret);
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_INTBUFFER
|
||||
if (up_interrupt_context())
|
||||
{
|
||||
syslog_add_intbuffer(*buffer++);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DEBUGASSERT(g_syslog_channel->sc_force != NULL);
|
||||
g_syslog_channel->sc_force(*buffer++);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
else if (g_syslog_channel->sc_write)
|
||||
{
|
||||
nwritten = g_syslog_channel->sc_write(buffer, buflen);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
DEBUGASSERT(g_syslog_channel->sc_putc != NULL);
|
||||
g_syslog_channel->sc_putc(*buffer++);
|
||||
}
|
||||
}
|
||||
|
||||
return buflen;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: syslog_write
|
||||
*
|
||||
@ -102,22 +130,15 @@ ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
|
||||
|
||||
ssize_t syslog_write(FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
#ifdef CONFIG_SYSLOG_INTBUFFER
|
||||
if (!up_interrupt_context() && !sched_idletask())
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_INTBUFFER
|
||||
/* Flush any characters that may have been added to the interrupt
|
||||
* buffer.
|
||||
*/
|
||||
|
||||
(void)syslog_flush_intbuffer(g_syslog_channel, false);
|
||||
#endif
|
||||
|
||||
return g_syslog_channel->sc_write(buffer, buflen);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return syslog_default_write(buffer, buflen);
|
||||
}
|
||||
return syslog_default_write(buffer, buflen);
|
||||
}
|
||||
|
@ -114,12 +114,12 @@ struct syslog_channel_s
|
||||
{
|
||||
/* I/O redirection methods */
|
||||
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_write_t sc_write; /* Write multiple bytes */
|
||||
#endif
|
||||
syslog_putc_t sc_putc; /* Normal buffered output */
|
||||
syslog_putc_t sc_force; /* Low-level output for interrupt handlers */
|
||||
syslog_flush_t sc_flush; /* Flush buffered output (on crash) */
|
||||
#ifdef CONFIG_SYSLOG_WRITE
|
||||
syslog_write_t sc_write; /* Write multiple bytes */
|
||||
#endif
|
||||
|
||||
/* Implementation specific logic may follow */
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user