Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen add more locking (when we read and write fields)
details: https://anonhg.NetBSD.org/src/rev/d8f6ea09e76c
branches: trunk
changeset: 781981:d8f6ea09e76c
user: christos <christos%NetBSD.org@localhost>
date: Wed Oct 10 23:53:43 2012 +0000
description:
add more locking (when we read and write fields)
diffstat:
lib/libc/gen/syslog.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (52 lines):
diff -r 9153b7590043 -r d8f6ea09e76c lib/libc/gen/syslog.c
--- a/lib/libc/gen/syslog.c Wed Oct 10 22:52:26 2012 +0000
+++ b/lib/libc/gen/syslog.c Wed Oct 10 23:53:43 2012 +0000
@@ -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 @@
}
} 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 @@
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;
Home |
Main Index |
Thread Index |
Old Index