[rsyslog-notify] Forum Thread: Re: high cpu usage after reboot on FreeBSD - (Mode 'reply')
noreply at adiscon.com
noreply at adiscon.com
Tue May 26 22:24:14 CEST 2015
User: fenyo
Forumlink: http://kb.monitorware.com/viewtopic.php?p=25652#p25652
Message:
----------
I've just encountered rsyslog jumping up to the top of top using 100% of
one CPU core, on FreeBSD 10.1.
This bug is due to the syscall revoke("/dev/console") being called by
/sbin/init at the near end of the FreeBSD boot.
Here are the steps that occur at boot time and make this bug appear:
1- when /sbin/init launches rc scripts, rsyslogd starts
2- rsyslogd reads rsyslog.conf and if some stuff must be logged to the
console, because of a line like "*.err;kern.warning;auth.notice;mail.crit
/dev/console" in the configuration file, the daemon calls open to get a
file descriptor to write on "/dev/console". It starts writing corresponding
logs to this descriptor.
3- Later during the boot sequence, init configures the console, and for
this to be done, it starts by calling the revoke syscall:
revoke("/dev/console").
4- Once /dev/console is revoked, further writes to any file descriptor
previously opened on this file return -1 with ENXIO as errno, even if this
descriptor was opened in another process than init.
5- thus, rsyslogd gets this error in runtime/stream.c:doWriteCall(), and
calls runtime/stream.c:tryTTYRecover() since the error occured on a tty.
6- but runtime/stream.c:tryTTYRecover() tries to reopen the tty only if the
error is EIO on Linux or EBADF on any other operating system. Since the
error is ENXIO, that is distinct from EBADF,
runtime/stream.c:tryTTYRecover() returns RS_RET_OK and
runtime/stream.c:doWriteCall() loops, endlessly.
Here is a patch to apply to rsyslog to get rid of this bug:
[code:1qhff5rx]
--- runtime/stream.c.orig 2015-05-24 18:22:24.660946067
+0200
+++ runtime/stream.c 2015-05-24 18:29:47.144801920 +0200
@@ -997,7 +997,11 @@
{
DEFiRet;
ISOBJ_TYPE_assert(pThis, strm);
+#ifndef __FreeBSD__
if(err == ERR_TTYHUP) {
+#else
+ if(err == ERR_TTYHUP || err == ENXIO) {
+#endif /* __FreeBSD__ */
close(pThis->fd);
CHKiRet(doPhysOpen(pThis));
}
[/code:1qhff5rx]
More information about the rsyslog-notify
mailing list