[BusyBox] Re: syslogd sometimes dies writing to remote logger

larry at doolittle.boa.org larry at doolittle.boa.org
Mon Apr 1 23:13:03 UTC 2002


> syslogd: syslogd: cannot write to remote file handle on 192.168.26.1:514

I looked at the source code in 0.60.2 (did 0.60.3 ever come out?)
The error test in syslogd.c is too restrictive.
When a system calls like writev() fails, the user space
needs to check errno, since some errors are not really
errors.  EINTR is the usual culprit, and I suspect that's
the only legitimate one to check for in this case.  If
writev() returns -1, and errno is EINTR, you should retry
the writev() (in a loop).  Like this:

    writev_retry:
       if ( -1 == writev(remotefd,iov, IOV_COUNT)){
           if (errno == EINTR) goto writev_retry;
           error_msg_and_die("syslogd: cannot write to remote file handle on"
                 "%s:%d",RemoteHost,RemotePort);
       }

Purists should resist the urge to rewrite this without the goto,
since a goto is (in this case) the clearest way to express the intent.

        - Larry



More information about the busybox mailing list