syslog/syslog_rpmsg.c: the last log may be lost when it crashes
At line 236, we may set the null terminate to the priv->buffer, when flushing the priv->buffer, we should use up_putc() instead up_nputs() to ensure all the data has been output, because up_nputs() will check the null terminate but up_putc() not. Signed-off-by: yuanyongjian <yuanyongjian@xiaomi.com>
This commit is contained in:
parent
9e1750d22c
commit
6869a05368
|
@ -242,7 +242,6 @@ static void syslog_rpmsg_addbuf(FAR struct syslog_rpmsg_s *priv,
|
|||
#if defined(CONFIG_ARCH_LOWPUTC)
|
||||
up_nputs(buffer, len);
|
||||
#endif
|
||||
|
||||
priv->flush += len;
|
||||
return;
|
||||
}
|
||||
|
@ -389,13 +388,12 @@ int syslog_rpmsg_flush(FAR syslog_channel_t *channel)
|
|||
priv->flush = priv->tail;
|
||||
}
|
||||
|
||||
if (priv->flush < priv->head)
|
||||
while (priv->flush < priv->head)
|
||||
{
|
||||
size_t len = priv->head - priv->flush;
|
||||
#if defined(CONFIG_ARCH_LOWPUTC)
|
||||
up_nputs(&priv->buffer[SYSLOG_RPMSG_FLUSHOFF(priv)], len);
|
||||
up_putc(priv->buffer[SYSLOG_RPMSG_FLUSHOFF(priv)]);
|
||||
#endif
|
||||
priv->flush += len;
|
||||
priv->flush++;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
|
Loading…
Reference in New Issue