Module Name: src Committed By: christos Date: Tue Jun 19 13:44:35 UTC 2012
Modified Files: src/usr.sbin/syslogd: syslogd.c Log Message: - fix writev1() to pre-decrement count. - always open ttys with O_NDELAY. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.sbin/syslogd/syslogd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/syslogd/syslogd.c diff -u src/usr.sbin/syslogd/syslogd.c:1.110 src/usr.sbin/syslogd/syslogd.c:1.111 --- src/usr.sbin/syslogd/syslogd.c:1.110 Mon Jun 18 15:17:42 2012 +++ src/usr.sbin/syslogd/syslogd.c Tue Jun 19 09:44:35 2012 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #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 @@ fprintlog(struct filed *f, struct buf_ms */ 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 @@ cfline(size_t linenum, const char *line, 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 @@ writev1(int fd, struct iovec *iov, size_ 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 @@ writev1(int fd, struct iovec *iov, size_ pfd.revents = 0; (void)poll(&pfd, 1, 500); continue; - } else - return -1; + } + return -1; case 0: return 0; default: @@ -4727,10 +4729,11 @@ writev1(int fd, struct iovec *iov, size_ 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++;