Minor fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16553 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-04-27 07:39:02 +00:00
parent e413e4b77d
commit 71b97ccade
3 changed files with 32 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2003-04-27 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: ([synchronize]) fix locking to permit
recursive call to this method, ensuring the distributed lock is
only obtained once.
2003-04-17 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/gnustep/base/GSCategories.h:

View file

@ -138,7 +138,7 @@ static NSFileManager *mgr = nil;
}
/**
* Returns the date at which the lock was aquired by any
* Returns the date at which the lock was aquired by <em>any</em>
* NSDistributedLock using the same path. If nothing has
* the lock, this returns nil.
*/

View file

@ -1321,10 +1321,13 @@ static BOOL isPlistObject(id o)
NSDate *started = [NSDateClass date];
unsigned long desired;
unsigned long attributes;
static BOOL isLocked = NO;
BOOL wasLocked;
[_lock lock];
if (_fileLock != nil)
wasLocked = isLocked;
if (isLocked == NO && _fileLock != nil)
{
while ([_fileLock tryLock] == NO)
{
@ -1364,6 +1367,7 @@ static BOOL isPlistObject(id o)
}
RELEASE(arp);
}
isLocked = YES;
}
/*
@ -1403,7 +1407,11 @@ static BOOL isPlistObject(id o)
}
if (wantRead == NO)
{
[_fileLock unlock];
if (wasLocked == NO)
{
[_fileLock unlock];
isLocked = NO;
}
[_lock unlock];
return YES;
}
@ -1431,7 +1439,11 @@ static BOOL isPlistObject(id o)
if (newDict == nil)
{
NSLog(@"Unable to load defaults from '%@'", _defaultsDatabase);
[_fileLock unlock];
if (wasLocked == NO)
{
[_fileLock unlock];
isLocked = NO;
}
[_lock unlock];
return NO;
}
@ -1488,7 +1500,11 @@ static BOOL isPlistObject(id o)
{
if (![_persDomains writeToFile: _defaultsDatabase atomically: YES])
{
[_fileLock unlock];
if (wasLocked == NO)
{
[_fileLock unlock];
isLocked = NO;
}
[_lock unlock];
return NO;
}
@ -1513,7 +1529,11 @@ static BOOL isPlistObject(id o)
}
}
[_fileLock unlock];
if (wasLocked == NO)
{
[_fileLock unlock];
isLocked = NO;
}
[_lock unlock];
return YES;
}