Author: rfm
Date: Mon Mar 14 09:26:41 2016
New Revision: 39537

URL: http://svn.gna.org/viewcvs/gnustep?rev=39537&view=rev
Log:
Add some diagnostics for defaults locking

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Source/NSDistributedLock.m
    libs/base/trunk/Source/NSUserDefaults.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39537&r1=39536&r2=39537&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Mon Mar 14 09:26:41 2016
@@ -1,3 +1,8 @@
+2016-03-14  Richard Frith-Macdonald <[email protected]>
+
+       * Source/NSUserDefaults.m: Log is we break the lock.
+       * Source/NSDistributedLock.m: Unlock if dealloc'ed while locked.
+
 2016-03-12  Richard Frith-Macdonald <[email protected]>
 
        * Source/NSUserDefaults.m: Remove five year old code for converting

Modified: libs/base/trunk/Source/NSDistributedLock.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSDistributedLock.m?rev=39537&r1=39536&r2=39537&view=diff
==============================================================================
--- libs/base/trunk/Source/NSDistributedLock.m  (original)
+++ libs/base/trunk/Source/NSDistributedLock.m  Mon Mar 14 09:26:41 2016
@@ -99,6 +99,12 @@
 
 - (void) dealloc
 {
+  if (_lockTime != nil)
+    {
+      NSLog(@"[%@-dealloc] still locked for %@ since %@",
+        NSStringFromClass([self class]), _lockPath, _lockTime);
+      [self unlock];
+    }
   RELEASE(_lockPath);
   RELEASE(_lockTime);
   [super dealloc];
@@ -214,7 +220,7 @@
          if (locked == NO)
            {
              NSLog(@"Failed to create lock directory '%@' - %@",
-                   _lockPath, [NSError _last]);
+                _lockPath, [NSError _last]);
            }
        }
     }
@@ -230,7 +236,8 @@
       if (attributes == nil)
        {
          [NSException raise: NSGenericException
-                     format: @"Unable to get attributes of lock file we made"];
+            format: @"Unable to get attributes of lock file we made at %@",
+            _lockPath];
        }
       ASSIGN(_lockTime, [attributes fileModificationDate]);
       return YES;

Modified: libs/base/trunk/Source/NSUserDefaults.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSUserDefaults.m?rev=39537&r1=39536&r2=39537&view=diff
==============================================================================
--- libs/base/trunk/Source/NSUserDefaults.m     (original)
+++ libs/base/trunk/Source/NSUserDefaults.m     Mon Mar 14 09:26:41 2016
@@ -2357,13 +2357,15 @@
                   break;
                 }
 
-              /*
-               * If lockDate is nil, we should be able to lock again ... but we
+              /* If lockDate is nil, we should be able to lock again ... but we
                * 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] > 
5.0)
+              if (lockDate != nil
+                && [when timeIntervalSinceDate: lockDate] > 5.0)
                 {
+                  NSLog(@"NSUserdefaults file lock at %@ is dated %@ ... 
break",
+                    _fileLock, lockDate);
                   [_fileLock breakLock];
                 }
               else


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to