Proposing to call setlocale( LC_ALL, "C" ) in msSetup()

Frank Warmerdam warmerdam at POBOX.COM
Fri Apr 28 10:28:13 EDT 2006


Umberto Nicoletti wrote:
> Hi Frank.
> 
> First is thread safety: I have read somewhere but I have lost the link
> that atof is thread safe unless setlocale is called while executing.
> This could happen if we call setlocale from within gdal and reset it
> afterwards.

Umberto,

This is a good point, and a great danger in the "frequent calls
to setlocale()" approach to dealing with the issue.

> Second the Java VM respects the LANG and LC_* variables so changing
> the locale internally and   for small execution intervals will almost
> certainly cause incosistent behaviour at different times in the jvm: a
> number could be parsed in the C locale at one time and in the it_IT
> another. Even worse this could affect the whole tomcat process which
> could be running many other apps too.

I don't think that setlocale() changes the LANG or LC_ environment
variables.  So it should only affect stuff using the C runtime, not
JVM stuff that manages it's locale handling separately from the C
runtime.

>> I can certainly forsee problems if mapscript is loaded into apache,
>> in that our setlocale() action may affect all other activity using
>> the c runtime in Apache.  Is that the sort of issue you are concerned
>> about?
> 
> Exactly.

Of course there is still general danger.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org



More information about the mapserver-dev mailing list