tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: New syslog openlog option?



In article <20100414075432.GA13628%drowsy.duskware.de@localhost>,
Martin Husemann  <martin%duskware.de@localhost> wrote:
>Hi folks,
>
>I have been debugging a strange problem in a pretty minimal setup where
>init failed to exec the custom getty once reaching multiuser. Leaving out
>all the details, this was pretty tough to attack because in my setup there
>is no syslogd running, so the syslog calls from init go straight to the
>console. However, since syslog does not want to block on a stopped console,
>it opens /dev/console in nonblocking mode. In my case this led to all messages
>from init being randomly truncated.
>
>For now I've fixed this by just (locally) commenting out the nonblocking flag
>in the syslog function, but I wonder if there is (or should?) be some better
>way to handle this w/o source changes.
>
>How about a openlog flag that tells syslog to avoid nonblocking console IO,
>and init using that untill the first getty has been successfully spawned,
>then revoking it?
>
>But maybe it is too much of a hack for a special case.
>
>Am I overlooking other easy ways to help in this scenario?

Does changing the writev() in syslog.c with the following (untested) help?

christos

int
writev1(int fd, struct iovec *iov, size_t count)
{
        ssize_t nw = 0, tot = 0;
        size_t ntries = 5;

        while (ntries--) {
                while ((nw = writev(fd, iov, count)) > 0) {
                        tot += nw;
                        while (nw > 0) {
                                if (iov->iov_len > nw) {
                                        iov->iov_len -= nw;
                                        iov->iov_base += nw;
                                        break;
                                } else {
                                        if (count-- == 0)
                                                return tot;
                                        nw -= iov->iov_len;
                                        iov++;
                                }
                        }
                }
        }
        return tot == 0 ? nw : tot;
}



Home | Main Index | Thread Index | Old Index