Summary:ASTERISK-00165: [patch] Voicemailmain2 causes localtime_r() to return inconsistent results
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2003-08-25 12:34:52Date Closed:2008-01-15 14:34:20.000-0600
Versions:Frequency of
Environment:Attachments:( 0) ast_localtime.diff
( 1) ast_localtime.tgz
( 2) ast_localtime.tgz
( 3) ast_localtime.tgz
Description:app_voicemailmain2, to implement alternate timezones when playing back the date/time a message is received, changes the TZ environmental variable briefly.  Should any other thread call localtime_r() during this time, the results will be of that alternate timezone, not of the native process.  Because app_voicemailmain2 does return the TZ environmental variable to its default when done, later calls to localtime_r() may have results in different timezones.


I'm working on creating an alternative to localtime_r(), called ast_localtime(), which does not change the environmental variable.  Instead, the timezone will be passed directly as a parameter.  The environment will only be used as a default (in case of NULL).

This bug/race condition does not affect most installations, if no user listens to voicemailmain2 with a timezone other than the native timezone set on that machine.
Comments:By: John Todd (jtodd) 2003-09-08 17:52:43

Seems to work with ./test but I'm afraid I'm unclear on how to test from within asterisk.

By: Tilghman Lesher (tilghman) 2003-09-08 18:31:53

It's not actually used yet within Asterisk.  I'd like others to look at the code, before we change calls to localtime_r() to ast_localtime() -- not everywhere, just where the alternate timezones are needed, such as within app_voicemail and/or say.c.

By: Tilghman Lesher (tilghman) 2003-09-10 00:00:00

The 3rd and 4th files attached should resolve this bug.

By: John Todd (jtodd) 2003-09-12 17:51:36

Patch applied, and seems to work.  (at least, no crashes. ;)  My machines are in GMT, but my tz variables are set in voicemail.conf - things seem stable.

By: Mark Spencer (markster) 2003-09-13 15:50:57

Merged in CVS (with minor cleanups)

By: Digium Subversion (svnbot) 2008-01-15 14:34:20.000-0600

Repository: asterisk
Revision: 1506

U   trunk/Makefile
U   trunk/apps/app_voicemail2.c
A   trunk/include/asterisk/localtime.h
U   trunk/include/asterisk/pbx.h
U   trunk/include/asterisk/say.h
U   trunk/pbx.c
U   trunk/say.c
A   trunk/stdtime/
A   trunk/stdtime/Makefile
A   trunk/stdtime/localtime.c
A   trunk/stdtime/private.h
A   trunk/stdtime/test.c
A   trunk/stdtime/tzfile.h

r1506 | markster | 2008-01-15 14:34:19 -0600 (Tue, 15 Jan 2008) | 2 lines

CLeanup PBX patch and add localtime stuff for saytime (bug ASTERISK-165)