Re: [syslog-ng]syslog-ng doesn't properly close file sources?
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
Balazs Scheidler writes:
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.
On NetBSD, it appears that only one process is allowed to open /dev/klog at a time. So syslog-ng gets a "device busy" error when reinitializing, since it still has the file open under a different (though soon to be closed) fd. That's also why it worked fine with regular files when I was testing earlier: they didn't care if they were opened twice.
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: [...]
you'll need scsh to rebuild the sources.
I installed scsh-0.6.0 (and scheme48-0.57 just to be on the safe side, though I don't think that was necessary), but I'm having problems trying to regenerate affile.c.x. make_class uses some unusual #! escapes which don't behave under NetBSD, so I tried using "scsh -s make_class", but that didn't work for me either: $ pwd /usr/local/src/syslog-ng-1.5.14/src $ cp /pkg/libol-0.3.1/bin/make_class . $ scsh -s ./make_class < affile.c > affile.c.x Warning: use of macro doesn't match definition (syntax-rules '() ((let-and (expr) clause clauses ...) (and expr (let-and clause clauses ...))) ((let-and (name expr) clause clauses ...) (let ((name expr)) (and name (let-and clause clauses ...)))) ((let-and expr) expr)) Error: attempt to call a non-procedure ('syntax-error '(#{Name let-and} ((pair? expr)) (op-matches (match # #)) (arg-matches (match # #)) (append op-matches arg-matches)) '#{Procedure 2489 (unnamed in make-name-generator in names)} '#{Procedure 2486 (unnamed in make-keyword-comparator in names)}) -------------- BTW, here's what happens with make class: $ uname -s -r NetBSD 1.5.2 $ head /usr/local/bin/make_class #! \ -e main -s !# ;; Reads a C source file on stdin. Comments of the form ;; ;; /* ;; CLASS: ;; expression ;; */ $ /usr/local/bin/make_class bash: /usr/local/bin/make_class: No such file or directory
On Wed, Feb 06, 2002 at 03:32:33PM -0500, Ed Ravin wrote:
BTW, here's what happens with make class:
$ uname -s -r NetBSD 1.5.2
$ head /usr/local/bin/make_class #! \ -e main -s !#
the libol configure script didn't find scsh, you could add it to the first line after #!. -- Bazsi PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1
Balazs Scheidler writes:
On Wed, Feb 06, 2002 at 03:32:33PM -0500, Ed Ravin wrote:
BTW, here's what happens with make class:
$ uname -s -r NetBSD 1.5.2
$ head /usr/local/bin/make_class #! \ -e main -s !#
the libol configure script didn't find scsh, you could add it to the first line after #!.
Yes, I figured that out after I posted, and when I reconfigured libol the make_class script had a working #! line. Of course, that made no difference - the script still failed with the same errors as when I ran it with "scsh -s ./make_class". "scsh -e main -s ./make_class" also failed. Bazsi, can you put me out of my misery and send the updated affile.c.x ? :-)
participants (2)
-
Balazs Scheidler
-
Ed Ravin