Fix syslog messages lost if syslogd is temporary busy
commiteaedbdaa0877ec6d0501b8c19ad5175c80764c67
authorVladislav Grishenko <themiron@mail.ru>
Wed, 12 Sep 2012 12:04:48 +0000 (12 18:04 +0600)
committerWaldemar Brodkorb <wbx@openadk.org>
Thu, 17 Dec 2015 19:35:20 +0000 (17 20:35 +0100)
tree6c5d538517ff5b9d9d5f8ad7a643eeba958c4093
parent64917add7f4aeec8720d2fba5e96ea39aac35623
Fix syslog messages lost if syslogd is temporary busy

Commit 4139fe5aec935ba3f462dcaf6aafb6e5eadf1ab9 fixes SIGSTOPed syslogd issue.
but introduced new one - messages will be lost when socket buffer gets full,
not only if syslogd is stalled, but even if it accepts message slower than
someone sends and possibly leads to security hole, when important messages get
lost as result of attacker flooding.

Patch adds 1 second waiting for socket buffer can accept the message, helps
when syslogd is working hard. If it's stalled/SIGSTOPed, message will be sent
to errout as before. After that, further non-blocking /dev/log connect attempts
will fail immediately with EAGAIN error until syslogd reads some from it.

function                                             old     new   delta
openlog_intern                                       259     355     +96
static.tv                                              -       8      +8
.rodata                                              151     159      +8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 112/0)             Total: 112 bytes

Signed-off-by: Vladislav Grishenko <themiron@mail.ru>
libc/misc/syslog/syslog.c