Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/syslogd - fix writev1() to pre-decrement count.
details: https://anonhg.NetBSD.org/src/rev/fde46e4bbbae
branches: trunk
changeset: 779798:fde46e4bbbae
user: christos <christos%NetBSD.org@localhost>
date: Tue Jun 19 13:44:35 2012 +0000
description:
- fix writev1() to pre-decrement count.
- always open ttys with O_NDELAY.
diffstat:
usr.sbin/syslogd/syslogd.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diffs (70 lines):
diff -r 201322e320de -r fde46e4bbbae usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c Tue Jun 19 13:02:47 2012 +0000
+++ b/usr.sbin/syslogd/syslogd.c Tue Jun 19 13:44:35 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $ */
+/* $NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos 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.110 2012/06/18 19:17:42 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.111 2012/06/19 13:44:35 christos Exp $");
#endif
#endif /* not lint */
@@ -2422,7 +2422,7 @@
*/
if ((e == EIO || e == EBADF) && f->f_type != F_FILE) {
f->f_file = open(f->f_un.f_fname,
- O_WRONLY|O_APPEND|O_NDELAY, 0);
+ O_WRONLY|O_APPEND|O_NDELAY|O_NONBLOCK, 0);
if (f->f_file < 0) {
f->f_type = F_UNUSED;
logerror("%s", f->f_un.f_fname);
@@ -3822,7 +3822,7 @@
f->f_flags |= FFLAG_SIGN;
#endif /* !DISABLE_SIGN */
(void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname));
- if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) {
+ if ((f->f_file = open(p, O_WRONLY|O_APPEND|O_NDELAY, 0)) < 0) {
f->f_type = F_UNUSED;
logerror("%s", p);
break;
@@ -4708,6 +4708,8 @@
ssize_t nw = 0, tot = 0;
size_t ntries = 5;
+ if (count == 0)
+ return 0;
while (ntries--) {
switch ((nw = writev(fd, iov, count))) {
case -1:
@@ -4718,8 +4720,8 @@
pfd.revents = 0;
(void)poll(&pfd, 1, 500);
continue;
- } else
- return -1;
+ }
+ return -1;
case 0:
return 0;
default:
@@ -4727,10 +4729,11 @@
while (nw > 0) {
if (iov->iov_len > (size_t)nw) {
iov->iov_len -= nw;
- iov->iov_base = (char *)iov->iov_base + nw;
+ iov->iov_base =
+ (char *)iov->iov_base + nw;
break;
} else {
- if (count-- == 0)
+ if (--count == 0)
return tot;
nw -= iov->iov_len;
iov++;
Home |
Main Index |
Thread Index |
Old Index