Module Name: src
Committed By: christos
Date: Wed Oct 10 23:53:43 UTC 2012
Modified Files:
src/lib/libc/gen: syslog.c
Log Message:
add more locking (when we read and write fields)
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libc/gen/syslog.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/gen/syslog.c
diff -u src/lib/libc/gen/syslog.c:1.51 src/lib/libc/gen/syslog.c:1.52
--- src/lib/libc/gen/syslog.c:1.51 Wed Oct 10 18:50:51 2012
+++ src/lib/libc/gen/syslog.c Wed Oct 10 19:53:43 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: syslog.c,v 1.51 2012/10/10 22:50:51 christos Exp $ */
+/* $NetBSD: syslog.c,v 1.52 2012/10/10 23:53:43 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95";
#else
-__RCSID("$NetBSD: syslog.c,v 1.51 2012/10/10 22:50:51 christos Exp $");
+__RCSID("$NetBSD: syslog.c,v 1.52 2012/10/10 23:53:43 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -289,13 +289,19 @@ vsyslogp_r(int pri, struct syslog_data *
}
} else {
prlen = snprintf_ss(p, tbuf_left, "-");
-
- /* if gmtime_r() was signal-safe we could output the UTC-time:
+#if 0
+ /*
+ * if gmtime_r() was signal-safe we could output
+ * the UTC-time:
+ */
gmtime_r(&now, &tmnow);
prlen = strftime(p, tbuf_left, "%FT%TZ", &tmnow);
- */
+#endif
}
+ if (data == &sdata)
+ mutex_lock(&syslog_mutex);
+
if (data->log_hostname[0] == '\0' && gethostname(data->log_hostname,
sizeof(data->log_hostname)) == -1) {
/* can this really happen? */
@@ -312,6 +318,10 @@ vsyslogp_r(int pri, struct syslog_data *
DEC();
prlen = snprintf_ss(p, tbuf_left, "%s ",
data->log_tag ? data->log_tag : "-");
+
+ if (data == &sdata)
+ mutex_unlock(&syslog_mutex);
+
if (data->log_stat & (LOG_PERROR|LOG_CONS)) {
iovcnt = 0;
iov[iovcnt].iov_base = p;