Re: syslog(3) blocks when local socket is full

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

 



(You're using a weird quote character.)

Luis Claudio R. Goncalves wrote:

I did some more testing, now with syslog turned off. The return code is
always 0, the program runs to completion - without hanging or without
waiting for any event. Turning syslog on, no singe log message from the
test program appears.

strace:

500 repetitions of:

 socket(PF_FILE, SOCK_DGRAM, 0)          = 3
 fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
 connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = -1 ENOENT
   (No such file or directory)
 close(3)                                = 0

The /dev/log file does not exist because syslogd removed it.
(A process must bind that "address" for the file to exist.)
The program tries to connect, and fails, 500 times.

My description of the setup was incorrect.

#include <syslog.h>
int main(void)
{
  int i;
  for (i=1; i <= 1000; ++i)
  {
    printf("Sending I=%d\n", i);
    syslog(LOG_INFO, "I=%d", i);
  }
  return 0;
}

1. start syslogd (the syslog daemon)
2. send syslogd the STOP signal
3. run the test program (it will block)
4. kill the test program
5. send syslogd the CONT signal

syslogd binds "/dev/log" which "creates" the socket:
$ ls -l /dev/log
srw-rw-rw- 1 root root 0 2007-10-08 09:36 /dev/log=

Anyway, the default for syslog is to be LOG_ODELAY, so it waits until the
connection is made before going on. That can be changed using LOG_NDELAY in
openlog().

LOG_NDELAY and LOG_ODELAY are a different matter.

Regards.
-
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux