mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Improved locking of initialization of gnustep_system_root, etc
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9676 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
94dbc95014
commit
eb52312f73
1 changed files with 23 additions and 18 deletions
|
@ -392,7 +392,7 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
|||
NSString *path;
|
||||
unsigned i, count;
|
||||
|
||||
if (gnustep_user_root == nil)
|
||||
if (gnustep_system_root == nil)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -400,26 +400,31 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
|||
|
||||
[gnustep_global_lock lock];
|
||||
|
||||
env = [[NSProcessInfo processInfo] environment];
|
||||
/* Any of the following might be nil */
|
||||
gnustep_system_root = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"];
|
||||
TEST_RETAIN (gnustep_system_root);
|
||||
/* Double-Locking Pattern */
|
||||
if (gnustep_system_root == nil)
|
||||
{
|
||||
/* This is pretty important as we need it to load
|
||||
character sets, language settings and similar
|
||||
resources. Use fprintf to avoid recursive calls. */
|
||||
fprintf (stderr,
|
||||
"Warning - GNUSTEP_SYSTEM_ROOT is not set "
|
||||
"- using /usr/GNUstep/System as a default\n");
|
||||
gnustep_system_root = @"/usr/GNUstep/System";
|
||||
env = [[NSProcessInfo processInfo] environment];
|
||||
/* Any of the following might be nil */
|
||||
gnustep_system_root = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"];
|
||||
TEST_RETAIN (gnustep_system_root);
|
||||
if (gnustep_system_root == nil)
|
||||
{
|
||||
/* This is pretty important as we need it to load
|
||||
character sets, language settings and similar
|
||||
resources. Use fprintf to avoid recursive calls. */
|
||||
fprintf (stderr,
|
||||
"Warning - GNUSTEP_SYSTEM_ROOT is not set "
|
||||
"- using /usr/GNUstep/System as a default\n");
|
||||
gnustep_system_root = @"/usr/GNUstep/System";
|
||||
}
|
||||
gnustep_local_root = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"];
|
||||
TEST_RETAIN (gnustep_local_root);
|
||||
gnustep_network_root = [env objectForKey:
|
||||
@"GNUSTEP_NETWORK_ROOT"];
|
||||
TEST_RETAIN (gnustep_network_root);
|
||||
gnustep_user_root = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
TEST_RETAIN (gnustep_user_root);
|
||||
}
|
||||
gnustep_local_root = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"];
|
||||
TEST_RETAIN (gnustep_local_root);
|
||||
gnustep_network_root = [env objectForKey: @"GNUSTEP_NETWORK_ROOT"];
|
||||
TEST_RETAIN (gnustep_network_root);
|
||||
gnustep_user_root = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
||||
TEST_RETAIN (gnustep_user_root);
|
||||
|
||||
[gnustep_global_lock unlock];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue