[Asterisk-Dev] ast_localtime() and other atrocities

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Mon Sep 8 13:07:06 MST 2003


Okay, this is a set of files to add a number of functions to
 asterisk, as replacements for localtime_r(), mktime(), etc.

Why is this functionality needed?  Well, it wasn't, until I added the
datetime prompts to VoicemailMain2, which features hearing prompts
customized to each user, some users in different timezones.
Unfortunately, this created a race condition, because the libc
implementation of localtime_r() depends upon an environmental
variable, TZ, which contains the current timezone.  Should that
environmental variable change, localtime_r() will return results in
a different timezone.  Add to this the multi-thread runtime (but only
one environment) of asterisk, and you may have mysterious timing
problems.

Of course, if you don't use VoicemailMain2 in a timezone other than
the timezone of the native machine (and I imagine most people don't),
this won't be a problem.  However, I'd like to solve the problem
before it becomes an issue.  Hence, this patch.

This tar/gz contains several additional files and a patch to the main
Asterisk Makefile.  The ast_localtime function has been tested and
has been determined to work (in at least all four main American
timezones).  I'm not done here, but I'm reasonably progressed enough
to allow for the "many eyes" principle to start on this code (i.e.
this is beta code).

Of course, another question might be, why is this code being added
to the central Asterisk code and not to the VoicemailMain2
 application code?  The reason is that some of the functionality of
 VoicemailMain2 will be abstracted out to say.c, so that any
 application may take advantage of the code to pronounce the date and
 time.

Comments, patches, etc. are appreciated.

http://bugs.digium.com/file_download.php?file_id=105&type=bug

-Tilghman




More information about the asterisk-dev mailing list