[syslog-ng]syslog-ng doesn't properly close file sources?

Balazs Scheidler bazsi@balabit.hu
Wed, 6 Feb 2002 16:09:35 +0100


On Tue, Feb 05, 2002 at 07:58:18PM -0500, Ed Ravin wrote:
> Sorry to be a pest, but did you ever get a chance to look at this?
> It's still happening in 1.5.14 on NetBSD 1.5.2.  A new backtrace
> is below.
> 
> I am willing to try and fix it myself, but it would really help if
> you could point me in the right direction.  I see in main.c that a
> HUP triggers io_callout(...) which goes to libol - is the problem
> there or is it just a matter of setting up the right callback stuff
> for flush or close in affile.c?

I've checked it out by then, and it did close the file source, but after
reinitializing the configuration. It works on Linux, but doesn't on NetBSD
as it seems.

I patched my tree on my notebook to close the fd earlier, but I forgot to
include it in 1.5.14. Here's the patch:

diff -u -r1.45 affile.c
--- affile.c	2002/02/05 15:49:05	1.45
+++ affile.c	2002/02/06 15:03:44
@@ -106,6 +106,7 @@
      (name affile_source)
      (super log_source_driver)
      (vars
+       (res pointer "struct resource_node")
        (flags . UINT32)
        (src object io_fd)
        (name string)))
@@ -122,13 +123,11 @@
   	else
 	  	flags = O_RDONLY | O_NOCTTY | O_NONBLOCK;
 	if (do_open_file(self->name, flags, -1, -1, -1, -1, -1, -1, 0, &fd)) {
-		struct resource_node *res;
-
 		lseek(fd, 0, SEEK_END);
 		self->src = io_read(make_io_fd(cfg->backend, fd, ol_string_use(self->name)), 
 			make_log_reader(0, c), 
 			NULL);
-		res = REMEMBER_RESOURCE(cfg->resources, &self->src->super.super);
+		self->res = REMEMBER_RESOURCE(cfg->resources, &self->src->super.super);
 		return ST_OK | ST_GOON;
 	}
 	else {
@@ -144,12 +143,20 @@
 	HANDLE_LOG(self->super.super.next, log);
 }
 
+static void do_destroy_affile_source(struct log_handler *c, struct syslog_config *cfg, struct persistent_config *persist)
+{
+	CAST(affile_source, self, c);
+	if (self->res)
+  		KILL_RESOURCE_NODE(cfg->resources, self->res);
+}
+
 struct log_source_driver *make_affile_source(const char *name, int flags)
 {
 	NEW(affile_source, self);
   
 	self->super.super.super.init = do_init_affile_source;
 	self->super.super.super.handler = do_affile_handle_line;
+	self->super.super.super.destroy = do_destroy_affile_source;
 	self->name = c_format_cstring("%z", name);
 	self->flags = flags;
 	return &self->super;


you'll need scsh to rebuild the sources.

-- 
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1