modperl and syslog, strange behavior

modperl and syslog, strange behavior

am 15.04.2008 23:03:51 von John Gateley

Hi Y'all,

I'm new to mod_perl, please forgive me if this is already well known
info.

I have several different web scripts like:

if($UseLog) {
Sys::Syslog::setlogsock('unix');
openlog("$WebScriptName", 'pid', 'daemon');
syslog('info', "$WebScriptName starting");
}
....
syslog('info', "Message"); # Actually buried in a subroutine
....

Originally, if $UseLog was false for an invocation of the script,
the "Message" would not appear in the syslog.

When I turned on mod_perl, sometimes I found "Message" appearing,
but under a different script's name.

So: mod_perl is somehow saving the socket state between runs of
webscripts, right?

Is it doing what it is supposed to be doing? Is there anything
wrong with what I am doing?

And most important - is there any other area that has the same or
similar behavior?

Thanks,

j

--
John Gateley

Re: modperl and syslog, strange behavior

am 16.04.2008 04:43:38 von Perrin Harkins

On Tue, Apr 15, 2008 at 5:03 PM, John Gateley wrote:
> if($UseLog) {
> Sys::Syslog::setlogsock('unix');
> openlog("$WebScriptName", 'pid', 'daemon');
> syslog('info', "$WebScriptName starting");
> }
> ...
> syslog('info', "Message"); # Actually buried in a subroutine
> ...
>
> Originally, if $UseLog was false for an invocation of the script,
> the "Message" would not appear in the syslog.
>
> When I turned on mod_perl, sometimes I found "Message" appearing,
> but under a different script's name.
>
> So: mod_perl is somehow saving the socket state between runs of
> webscripts, right?

The perl interpreter stays around, so yes, a socket opened will stay
open until you close it. That may or not be the problem. I'd suggest
you try closing it at the end of each request (maybe with a cleanup
handler) and see if that makes the problem go away.

- Perrin