[syslog-ng] syslog-ng blocking on read() from /proc/kmsg
Balazs Scheidler
bazsi at balabit.hu
Sun Apr 30 22:08:36 CEST 2006
On Thu, 2006-04-27 at 15:48 -0400, John Morrissey wrote:
> I'm running the Debian 1.6.9-1 package with the 'read from each file
> descriptor n times or until EAGAIN' patch backported. There seems to be a
> problem with this behavior when it's applied to /proc/kmsg. Here's the
> source we use:
>
> source s_kmsg {
> file("/proc/kmsg" log_prefix("kernel: "));
> };
>
/proc/kmsg does not support nonblocking mode, I already encountered this
earlier.
This could be called a kernel bug, however a workaround needs to be
implemented. Backing out the change will make the performance
improvements that we implemented void.
A possible solution is to avoid this multi-read behaviour for file
sources. Can you check if this patch fixes it?
Index: affile.c
===================================================================
RCS file: /var/cvs/syslog-ng/syslog-ng/src/affile.c,v
retrieving revision 1.61.4.5
diff -u -r1.61.4.5 affile.c
--- affile.c 5 Nov 2005 14:53:12 -0000 1.61.4.5
+++ affile.c 30 Apr 2006 20:06:49 -0000
@@ -162,7 +162,7 @@
io_set_nonblocking(fd);
lseek(fd, 0, SEEK_END);
self->src = io_read(make_io_fd(cfg->backend, fd, ol_string_use(self->name)),
- make_log_reader(0, self->prefix, cfg->log_msg_size, self->pad_size, cfg->check_hostname ? LF_CHECK_HOSTNAME : 0, cfg->bad_hostname, c),
+ make_log_reader(0, self->prefix, cfg->log_msg_size, self->pad_size, LF_NO_MULTI_READ | (cfg->check_hostname ? LF_CHECK_HOSTNAME : 0), cfg->bad_hostname, c),
NULL);
REMEMBER_RESOURCE(cfg->resources, &self->src->super.super);
return ST_OK | ST_GOON;
Index: log.h
===================================================================
RCS file: /var/cvs/syslog-ng/syslog-ng/src/log.h,v
retrieving revision 1.19
diff -u -r1.19 log.h
--- log.h 8 Jan 2003 09:31:37 -0000 1.19
+++ log.h 30 Apr 2006 20:06:50 -0000
@@ -57,6 +57,8 @@
#define LF_INTERNAL 0x0001
#define LF_MARK 0x0002
#define LF_LOCAL 0x0004
+/* hack, this is piggybacked to msg_flags instead of using a separate argument of make_log_reader */
+#define LF_NO_MULTI_READ 0x0008
#define LF_CHECK_HOSTNAME 0x0100
#define LF_USER_FLAGS 0xff00
Index: sources.c
===================================================================
RCS file: /var/cvs/syslog-ng/syslog-ng/src/sources.c,v
retrieving revision 1.37.4.9
diff -u -r1.37.4.9 sources.c
--- sources.c 13 Mar 2006 23:30:26 -0000 1.37.4.9
+++ sources.c 30 Apr 2006 20:06:50 -0000
@@ -87,8 +87,9 @@
char sabuf[256];
socklen_t salen = sizeof(sabuf);
int fetch_count = 0;
+ int fetch_max = (closure->msg_flags & LF_NO_MULTI_READ) ? 1 : 30;
- while (fetch_count < 30) {
+ while (fetch_count < fetch_max) {
if (!closure->dgram) {
if (closure->pad_size)
--
Bazsi
More information about the syslog-ng
mailing list