mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Pathces from Frith-MacDonald, Yamato, Jenkins.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2709 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49be21f6c3
commit
142cab5d90
10 changed files with 210 additions and 23 deletions
|
@ -49,6 +49,7 @@
|
|||
#include <Foundation/NSTimer.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSDistributedLock.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
|
||||
/* Wait for access */
|
||||
#define _MAX_COUNT 5 /* Max 10 sec. */
|
||||
|
@ -212,8 +213,23 @@ static NSMutableString *processName = nil;
|
|||
persDomains = [[NSMutableDictionary dictionaryWithCapacity:10] retain];
|
||||
if ([self synchronize] == NO)
|
||||
{
|
||||
[self dealloc];
|
||||
return self = nil;
|
||||
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
|
||||
BOOL done = NO;
|
||||
int attempts;
|
||||
|
||||
// Retry for a couple of seconds in case we are locked out.
|
||||
for (attempts = 0; done == NO && attempts < 10; attempts++)
|
||||
{
|
||||
[runLoop runMode: [runLoop currentMode]
|
||||
beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.2]];
|
||||
if ([self synchronize] == YES)
|
||||
done = YES;
|
||||
}
|
||||
if (done == NO)
|
||||
{
|
||||
[self dealloc];
|
||||
return self = nil;
|
||||
}
|
||||
}
|
||||
|
||||
// Check and if not existent add the Application and the Global domains
|
||||
|
@ -478,12 +494,14 @@ static NSMutableString *processName = nil;
|
|||
|
||||
// Get file lock - break any lock that is more than five minute old.
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
if ([[defaultsDatabaseLock lockDate] timeIntervalSinceNow] < 300.0)
|
||||
if ([[defaultsDatabaseLock lockDate] timeIntervalSinceNow] < -300.0)
|
||||
{
|
||||
[defaultsDatabaseLock breakLock];
|
||||
if ([defaultsDatabaseLock tryLock] == NO)
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
return NO;
|
||||
|
||||
// Read the persistent data from the stored database
|
||||
newDict = [[NSMutableDictionary allocWithZone:[self zone]]
|
||||
|
@ -510,7 +528,6 @@ static NSMutableString *processName = nil;
|
|||
// Save the changes
|
||||
if (![persDomains writeToFile:defaultsDatabase atomically:YES])
|
||||
{
|
||||
// NSLog(@"failed to write defaults to '%@'\n", defaultsDatabase);
|
||||
[defaultsDatabaseLock unlock];
|
||||
return NO;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue