Skip Menu |
 

This queue is for tickets about the Sys-Syslog CPAN distribution.

Report information
The Basics
Id: 17316
Status: resolved
Priority: 0/
Queue: Sys-Syslog

People
Owner: SAPER [...] cpan.org
Requestors: ric [...] opus1.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.13
Fixed in: 0.15



Subject: openlog() croak()s if daemon is down instead of returning error to caller
Download (untitled) / with headers
text/plain 522b
openlog("watcher","pid,ndelay","mail") croak()s if no syslog daemon is available. It would be much more useful if openlog() returned undef to the caller, so the application could use alternative error reporting. As it is, the error that was going to be logged is lost, and the application is aborted with unix dgram connect: Connection refused at daemon_watch.prl line 668 no connection to syslog available at daemon_watch.prl line 668 This is with perl, v5.8.6 built for i486-linux under Slackware Linux 10.1. --
Subject: RE: [rt.cpan.org #17316] AutoReply: openlog() croak()s if daemon is down instead of returning error to caller
Date: Fri, 27 Jan 2006 10:05:52 -0700
To: bug-Sys-Syslog [...] rt.cpan.org
From: Ric Anderson <ric [...] Opus1.COM>
Download (untitled) / with headers
text/plain 2.4k
Possible fix for problem noted below - --- Syslog.pm 2006-01-10 17:42:01.000000000 -0700 +++ ./blib/lib/Sys/Syslog.pm 2006-01-27 10:03:11.000000000 -0700 @@ -42,6 +42,7 @@ my $current_proto = undef; my $failed = undef; my $fail_time = undef; +my $lo_ndelay = undef; our ($connected, @fallbackMethods, $syslog_send, $host); use Socket ':all'; @@ -534,7 +535,7 @@ sub openlog { our ($ident, $logopt, $facility) = @_; # package vars our $lo_pid = $logopt =~ /\bpid\b/; - our $lo_ndelay = $logopt =~ /\bndelay\b/; + $lo_ndelay = $logopt =~ /\bndelay\b/; our $lo_nowait = $logopt =~ /\bnowait\b/; return 1 unless $lo_ndelay; &connect; @@ -798,6 +799,7 @@ $current_proto = $proto; my($old) = select(SYSLOG); $| = 1; select($old); } else { + return(undef) if($lo_ndelay); @fallbackMethods = (); croak join "\n\t- ", "no connection to syslog available", @errs } Show quoted text
> -----Original Message----- > From: Bugs in Sys-Syslog via RT [mailto:bug-Sys-Syslog@rt.cpan.org] > Sent: Friday, January 27, 2006 9:30 AM > To: ric@Opus1.COM > Subject: [rt.cpan.org #17316] AutoReply: openlog() croak()s > if daemon is down instead of returning error to caller > > > > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "openlog() croak()s if daemon is down instead of > returning error to caller", > a summary of which appears below. > > There is no need to reply to this message right now. Your > ticket has been > assigned an ID of [rt.cpan.org #17316]. > > Please include the string: > > [rt.cpan.org #17316] > > in the subject line of all future correspondence about this > issue. To do so, > you may reply to this message. > > Thank you, > bug-Sys-Syslog@rt.cpan.org > > -------------------------------------------------------------- > ----------- > openlog("watcher","pid,ndelay","mail") > croak()s if no syslog daemon is available. It would be much more > useful if openlog() returned undef to the caller, so the application > could use alternative error reporting. As it is, the error that was > going to be logged is lost, and the application is aborted with > unix dgram connect: Connection refused at daemon_watch.prl line 668 > no connection to syslog available at daemon_watch.prl line 668 > > This is with perl, v5.8.6 built for i486-linux under Slackware Linux > 10.1. > -- >
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Sun, 29 Jan 2006 23:41:03 +0100
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 1002b
Show quoted text
> openlog("watcher","pid,ndelay","mail") > croak()s if no syslog daemon is available. It would be much more > useful if openlog() returned undef to the caller, so the application > could use alternative error reporting. As it is, the error that was > going to be logged is lost, and the application is aborted with > unix dgram connect: Connection refused at daemon_watch.prl line 668 > no connection to syslog available at daemon_watch.prl line 668
I'm not very fond of this request: the module works exactly as documented, and since a long time, even before it was documented to do so. Looking at the source of old versions, back to the one included in 5.003, openlog() would croak() if it couldn't connect to a syslog service, so accessing your request would mean changing a decade-old behaviour. By the way, why not using the classical Perl way to handle exceptions: eval { openlog(...) }; doe something_else() if $@; -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Thu, 2 Feb 2006 01:49:26 +0100
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 173b
Hello, Didn't heard anything back from you. Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO
Subject: RE: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Wed, 01 Feb 2006 20:02:59 -0700
To: bug-Sys-Syslog [...] rt.cpan.org
From: Ric Anderson <ric [...] Opus1.COM>
Download (untitled) / with headers
text/plain 741b
Not much to say - my perspective is that openlog() should return the failure status to the app directly, rather than requiring what I view as a kludge based on eval(). Since you disagree, I guess you close the ticket as a "documented feature". Ric Show quoted text
> -----Original Message----- > From: Sébastien Aperghis-Tramoni via RT > [mailto:bug-Sys-Syslog@rt.cpan.org] > Sent: Wednesday, February 01, 2006 5:50 PM > To: ric@Opus1.COM > Subject: Re: [rt.cpan.org #17316] openlog() croak()s if > daemon is down instead of returning error to caller > > > Hello, > > Didn't heard anything back from you. > > > Sébastien Aperghis-Tramoni > -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] > Close the world, txEn eht nepO > >
Subject: RE: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Thu, 02 Feb 2006 09:45:07 +0100
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <maddingue [...] free.fr>
Download (untitled) / with headers
text/plain 497b
ric@opus1.com wrote: Show quoted text
> Not much to say - my perspective is that openlog() should > return the failure status to the app directly, rather than > requiring what I view as a kludge based on eval(). > > Since you disagree, I guess you close the ticket as a > "documented feature".
I can ask on P5P as Sys::Syslog is a core module that was CPANized very recently, but I think they'll also confirm that old behaviour must be preserved. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
From: eravin [...] panix.com
Download (untitled) / with headers
text/plain 1.9k
On Thu Feb 02 03:50:59 2006, maddingue@free.fr wrote: Show quoted text
> ric@opus1.com wrote: >
> > Not much to say - my perspective is that openlog() should > > return the failure status to the app directly, rather than > > requiring what I view as a kludge based on eval(). > > > > Since you disagree, I guess you close the ticket as a > > "documented feature".
> > I can ask on P5P as Sys::Syslog is a core module that was > CPANized very recently, but I think they'll also confirm > that old behaviour must be preserved.
I believe this "old behaviour" was an accident, and that no one is relying on it. It was not documented until I reported the problem in August 2005. Anyone who approaches Syslog.pm expecting it to behave more or less like the Unix syslog(3) is very surprised when this happens. The workaround is rather ugly - this is what I've had to put into all of my Perl daemons that use syslog: # Syslog.pm::syslog() has a fatal exit if syslogd is not running # The workaround is below. no warnings; # because we're redefining syslog() sub syslog { eval { local $SIG{"__DIE__"}= sub { }; Sys::Syslog::syslog(@_); } } use warnings; Since Sys::Syslog claims to be an interface to syslog(3) (even though it's not), I think it's a safe move to change it to behave more like syslog(3) and less like something that will crash an otherwise reliable Perl daemon. If that cannot be permitted, then at the very least, please add a "nofatal" flag that the caller can set to suppress fatal exits on outside errors. (I think the fatals on syntax or caller errors don't need to be suppressed, since those are presumably bugs in the Perl script, not outside conditions like syslogd going down.) I appreciate the recent code changes to Syslog.pm that added retry capability - that was missing in older versions. Of course, most users won't be able to use that retry capability unless they go the extra mile as shown above to suppress the fatal error first...
From: eravin [...] panix.com
Download (untitled) / with headers
text/plain 1.6k
On Wed May 31 18:09:52 2006, guest wrote: Show quoted text
> On Thu Feb 02 03:50:59 2006, maddingue@free.fr wrote:
... Show quoted text
> > I can ask on P5P as Sys::Syslog is a core module that was > > CPANized very recently, but I think they'll also confirm > > that old behaviour must be preserved.
I've thought a little bit more about this. The problems with the "old behavior" are bigger than previously thought. Here's how the "old behavior" worked: Sys::Syslog pre-CPAN-ized version 1a) if syslogd isn't running when openlog() is called, program gets fatal exception. 2a) if syslogd stops after openlog() is called, all subsequent syslog() calls are silently discarded. 3a) if syslogd is restarted after openlog() is called, all subsequent syslog() calls are silently discarded. And the current CPAN version, Sys::Syslog 0.14, behaves this way: 1b) if sylogd isn't running when openlog() is called, program gets fatal exception. (same behavior) 2b) if syslogd stops after openlog() is called, a subsequent syslog() call will provoke a reconnection attempt and get a fatal exception (new behavior) 3b) if syslogd is restarted after openlog() is called, a subsequent syslog() will provoke a reconnection attempt and the syslog messages will be logged normally. (new behavior) So the "old behavior" for (2a) above has now been changed to (2b) - a new case has been added where a user will get a surprise fatal exception. And the "old behavior" for (3a) has been changed to (3b) - syslog messages that used to be discarded are now being logged properly. So unless we get rid of the fatal error when the socket can't be connected, the recent changes actually introduce additional cases where a working Perl script will crash. -- Ed
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Sun, 4 Jun 2006 02:18:06 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 1.5k
Show quoted text
> I believe this "old behaviour" was an accident, and that no one is > relying on it. It was not documented until I reported the problem > in August 2005. Anyone who approaches Syslog.pm expecting it to behave > more or less like the Unix syslog(3) is very surprised when this > happens. > > The workaround is rather ugly - this is what I've had to put into > all of my Perl daemons that use syslog: [...]
Except there's no need to define a __DIE__ handler. Nesting a call inside an eval-block is enough to catch any die, and you can examine, or not, the message in $@. Show quoted text
> Since Sys::Syslog claims to be an interface to syslog(3) (even though > it's not), I think it's a safe move to change it to behave more like > syslog(3) and less like something that will crash an otherwise reliable > Perl daemon. If that cannot be permitted, then at the very least, > please add a "nofatal" flag that the caller can set to suppress fatal > exits on outside errors. (I think the fatals on syntax or caller > errors > don't need to be suppressed, since those are presumably bugs in the > Perl > script, not outside conditions like syslogd going down.)
Sorry if I look overly conservative, but I don't know how Sys::Syslog is used in the wild, that's why I prefer not to change the existing behaviour. On the other hand, adding new features like a "nofatal" option is perfectly acceptable. I note that one in my TODO list. Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Sun, 4 Jun 2006 03:20:41 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 709b
Show quoted text
> [snip] > So the "old behavior" for (2a) above has now been changed to (2b) - a > new case has been added where a user will get a surprise fatal > exception. And the "old behavior" for (3a) has been changed to (3b) - > syslog messages that used to be discarded are now being logged > properly. > > So unless we get rid of the fatal error when the socket can't be > connected, the recent changes actually introduce additional cases where > a working Perl script will crash.
Ok, I think you have a point, so I'll add a "nofatal" option. Thank you for your detailed analysis :-) Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO
From: eravin [...] panix.com
Download (untitled) / with headers
text/plain 1.1k
On Sat Jun 03 20:18:37 2006, SAPER wrote: Show quoted text
> Sorry if I look overly conservative, but I don't know how Sys::Syslog > is used in the wild, that's why I prefer not to change the existing > behaviour. On the other hand, adding new features like a "nofatal" > option is perfectly acceptable. I note that one in my TODO list.
I understand your reluctance to change an existing behavior, but as a user of Sys::Syslog (not just for myself - also on the open source project Mon (mon.sf.net), which doesn't expect to get killed by calling openlog() or syslog() ), I can't imagine that any programmer wants a fatal trap. Look at the sample code in the Sys::Syslog documentation, or at the various tutorials on the Web on how to use it. Everyone treats Sys::Syslog as a Perl implemntation of the Unix syslog(3), which doesn't even have return values, much less surprise fatal traps. Since this wasn't "documented behavior" until I filed perl bug 36848 last year, no one could have been coding their programs to use this behavior. I suggest that you make "nonfatal" the default setting, since it will fix far, far more programs than it will break. Thanks for re-visiting this problem... -- Ed
CC: bug-Sys-Syslog [...] rt.cpan.org
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Fri, 9 Jun 2006 00:31:55 +0200
To: Ed <eravin [...] panix.com>, Ric Anderson <ric [...] opus.com>
From: Sébastien Aperghis-Tramoni <maddingue [...] free.fr>
Download (untitled) / with headers
text/plain 636b
Show quoted text
> Sorry if I look overly conservative, but I don't know how Sys::Syslog > is used in the wild, that's why I prefer not to change the existing > behaviour. On the other hand, adding new features like a "nofatal" > option is perfectly acceptable. I note that one in my TODO list.
Here is a beta version of Sys::Syslog 0.15: http://maddingue.org/work/Sys-Syslog-0.15b1.tar.gz It includes the "nofatal" option, but disabled by default. Can you test it and tell me whether it better fits your expectations? Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO
CC: Ric Anderson <ric [...] opus.com>, bug-Sys-Syslog [...] rt.cpan.org
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Thu, 8 Jun 2006 20:46:16 -0400
To: S?bastien Aperghis-Tramoni <maddingue [...] free.fr>
From: Ed Ravin <eravin [...] panix.com>
Download (untitled) / with headers
text/plain 666b
On Fri, Jun 09, 2006 at 12:31:55AM +0200, S?bastien Aperghis-Tramoni wrote: Show quoted text
>
> >Sorry if I look overly conservative, but I don't know how Sys::Syslog > >is used in the wild, that's why I prefer not to change the existing > >behaviour. On the other hand, adding new features like a "nofatal" > >option is perfectly acceptable. I note that one in my TODO list.
> > Here is a beta version of Sys::Syslog 0.15: > http://maddingue.org/work/Sys-Syslog-0.15b1.tar.gz > > It includes the "nofatal" option, but disabled by default. > Can you test it and tell me whether it better fits your expectations?
Yes, turning on "nofatal" works as expected. Thanks, -- Ed
Subject: Re: [rt.cpan.org #17316] openlog() croak()s if daemon is down instead of returning error to caller
Date: Fri, 09 Jun 2006 09:53:53 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 437b
Show quoted text
> > Here is a beta version of Sys::Syslog 0.15: > > http://maddingue.org/work/Sys-Syslog-0.15b1.tar.gz > > > > It includes the "nofatal" option, but disabled by default. > > Can you test it and tell me whether it better fits your expectations?
> > Yes, turning on "nofatal" works as expected.
Nice. Now I need to write a few more tests, then release it on the CPAN. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.
Subject: [rt.cpan.org #17316] Fwd: CPAN Upload: S/SA/SAPER/Sys-Syslog-0.15.tar.gz
Date: Sun, 11 Jun 2006 18:21:22 +0200
To: bug-Sys-Syslog [...] rt.cpan.org
From: Sébastien Aperghis-Tramoni <saper [...] cpan.org>
Download (untitled) / with headers
text/plain 617b
This is now fixed in version 0.15. Thanks for your report. Begin forwarded message: Show quoted text
> From: PAUSE <upload@pause.perl.org> > Date: Sun June 11, 2006 01:57:14 Europe/Paris > To: "Sebastien Aperghis-Tramoni" <maddingue@free.fr> > Subject: CPAN Upload: S/SA/SAPER/Sys-Syslog-0.15.tar.gz > > The uploaded file > > Sys-Syslog-0.15.tar.gz > > has entered CPAN as > > file: $CPAN/authors/id/S/SA/SAPER/Sys-Syslog-0.15.tar.gz > size: 50616 bytes > md5: 1afe2987bf02630b0e4cfa087cea6504
Sébastien Aperghis-Tramoni -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ] Close the world, txEn eht nepO


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.