Author: rfm
Date: Wed Jun 22 15:21:04 2016
New Revision: 39905
URL: http://svn.gna.org/viewcvs/gnustep?rev=39905&view=rev
Log:
Tiny code simplification.
Modified:
libs/base/trunk/Source/NSDistributedLock.m
libs/base/trunk/Source/NSUserDefaults.m
Modified: libs/base/trunk/Source/NSDistributedLock.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSDistributedLock.m?rev=39905&r1=39904&r2=39905&view=diff
==============================================================================
--- libs/base/trunk/Source/NSDistributedLock.m (original)
+++ libs/base/trunk/Source/NSDistributedLock.m Wed Jun 22 15:21:04 2016
@@ -80,6 +80,10 @@
{
NSDictionary *attributes;
+ if (nil != _lockTime)
+ {
+ NSLog(@"Breaking our own distributed lock %@", _lockPath);
+ }
DESTROY(_lockTime);
attributes = [mgr fileAttributesAtPath: _lockPath traverseLink: YES];
if (attributes != nil)
Modified: libs/base/trunk/Source/NSUserDefaults.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSUserDefaults.m?rev=39905&r1=39904&r2=39905&view=diff
==============================================================================
--- libs/base/trunk/Source/NSUserDefaults.m (original)
+++ libs/base/trunk/Source/NSUserDefaults.m Wed Jun 22 15:21:04 2016
@@ -2332,11 +2332,7 @@
while ([_fileLock tryLock] == NO)
{
CREATE_AUTORELEASE_POOL(arp);
- NSDate *when;
NSDate *lockDate;
-
- lockDate = [_fileLock lockDate];
- when = [NSDateClass dateWithTimeIntervalSinceNow: 0.1];
/*
* In case we have tried and failed to break the lock,
@@ -2344,7 +2340,7 @@
* us three lock breaks if we do them at 20 second
* intervals.
*/
- if ([when timeIntervalSinceDate: started] > 66.0)
+ if ([started timeIntervalSinceNow] < -66.0)
{
fprintf(stderr, "Failed to lock user defaults database"
" even after breaking old locks!\n");
@@ -2356,16 +2352,16 @@
* wait a little anyway ... so that in the case of a locking
* problem we do an idle wait rather than a busy one.
*/
- if (lockDate != nil
- && [when timeIntervalSinceDate: lockDate] > 20.0)
+ if ((lockDate = [_fileLock lockDate]) != nil
+ && [lockDate timeIntervalSinceNow] < -20.0)
{
- NSLog(@"NSUserdefaults file lock at %@ is dated %@ ...
break",
+ NSLog(@"NSUserDefaults file lock at %@ is dated %@ ...
break",
_fileLock, lockDate);
[_fileLock breakLock];
}
else
{
- [NSThread sleepUntilDate: when];
+ [NSThread sleepForTimeInterval: 0.1];
}
RELEASE(arp);
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs