Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/syslogd Defer the processing of incomplete line at ...
details: https://anonhg.NetBSD.org/src/rev/a1204c471557
branches: trunk
changeset: 766264:a1204c471557
user: enami <enami%NetBSD.org@localhost>
date: Mon Jun 20 00:42:11 2011 +0000
description:
Defer the processing of incomplete line at the end of buffer so that
kernel printf messages logged to /var/log/messages become always
easier to read.
diffstat:
usr.sbin/syslogd/syslogd.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (64 lines):
diff -r c844b69a11e3 -r a1204c471557 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c Sun Jun 19 21:37:10 2011 +0000
+++ b/usr.sbin/syslogd/syslogd.c Mon Jun 20 00:42:11 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $ */
+/* $NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#else
-__RCSID("$NetBSD: syslogd.c,v 1.102 2011/05/24 13:26:04 joerg Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.103 2011/06/20 00:42:11 enami Exp $");
#endif
#endif /* not lint */
@@ -276,7 +276,7 @@
* a global one will do.
*/
char *linebuf;
-size_t linebufsize;
+size_t linebufsize, linebufoff;
static const char *bindhostname = NULL;
@@ -662,14 +662,15 @@
dispatch_read_klog(int fd, short event, void *ev)
{
ssize_t rv;
+ size_t resid = linebufsize - linebufoff;
DPRINTF((D_CALL|D_EVENT), "Kernel log active (%d, %d, %p)"
" with linebuf@%p, length %zu)\n", fd, event, ev,
linebuf, linebufsize);
- rv = read(fd, linebuf, linebufsize - 1);
+ rv = read(fd, &linebuf[linebufoff], resid - 1);
if (rv > 0) {
- linebuf[rv] = '\0';
+ linebuf[linebufoff + rv] = '\0';
printsys(linebuf);
} else if (rv < 0 && errno != EINTR) {
/*
@@ -1503,6 +1504,7 @@
char *p, *q;
struct buf_msg *buffer;
+ linebufoff = 0;
for (p = msg; *p != '\0'; ) {
bool bsdsyslog = true;
@@ -1534,6 +1536,10 @@
* trust the kernel to send ASCII only */;
if (*q != '\0')
*q++ = '\0';
+ else {
+ memcpy(linebuf, p, linebufoff = q - p);
+ break;
+ }
if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
pri = DEFSPRI;
Home |
Main Index |
Thread Index |
Old Index