Problems with localtime's use of the TZ environment var?
"Michael Richards" <michael-97jfqw80gc4sA/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
For the past few years I've had occasional and random bouts of internal
server errors. I've always assumed it to be a bug in the CGI (written in
c++). I've installed mpatrol recently and attempted to find and stomp
out this problem.
I've narrowed it down thus far:
#11 0x2835f99d in tzsetwall () from /lib/libc.so.5
#12 0x2835fd41 in localtime_r () from /lib/libc.so.5
#13 0x283602a5 in ctime_r () from /lib/libc.so.5
#14 0x28118eaa in TLogger::writeLog (this=0x805c000, filename=0x8055ef6
"request.cpp", lineno=248) at tlogger.cpp:65
In my logging routine it's fairly simple. It's been hacked up over time
but it looks somewhat like this:
time_t now=time(NULL);
std::string timestamp;
char ctimestamp[20];
ctime_r(&now,&ctimestamp[0]);
timestamp+=ctimestamp;
timestamp.erase(24);
(*logfile) << timestamp
<< " - (" << ourpid << ") "
<< filename << '(' << lineno << ')' << " - ";
logfile->flush();
The only thing I can think of is that somehow this is caching a pointer
to getenv(TZ) and accepting a request is messing with this. It seems to
happen about one in every 1000 log writes.
Does anyone have any input on my problem? I only partly know what I'm
doing here :)
-Michael
_________________________________________________________________
http://fastmail.ca/ - Fast Secure Web Email for Canadians
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/