diff --git a/ChangeLog b/ChangeLog index 7417c42dd..8133bfe67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016-10-24 04:03-EDT Gregory John Casamento + + * Source/NSWorkspace.m: Change to GSLaunchd(...) function to + correct lock issue which is ocurring on some systems. Added + a mutex lock to create a critical section and a retry mechanism + in case the distributed lock is not released on the first try. + This change appears to correct the issue. Tested by myself and + Riccardo. + 2016-10-23 Fred Kiefer * Source/NSWindow.m (NSMiniWindowView -setImage:): Try to handle @@ -10,6 +19,7 @@ * Source/NSLayoutManager.m: Use the pre-computed advancement instead of calculating it every time. +>>>>>>> .r40169 2016-10-22 Fred Kiefer * Source/GSLayoutManager.m: Don't try to get the advancement for diff --git a/Source/NSWorkspace.m b/Source/NSWorkspace.m index 226fa7c6a..08daa936a 100644 --- a/Source/NSWorkspace.m +++ b/Source/NSWorkspace.m @@ -133,7 +133,11 @@ static id GSLaunched(NSNotification *notification, BOOL active) NSString *name; NSDictionary *apps = nil; BOOL modified = NO; + unsigned sleeps = 0; + NSLock *mlock = nil; + mlock = [[NSLock alloc] init]; + [mlock lock]; // start critical section if (path == nil) { path = [NSTemporaryDirectory() @@ -144,8 +148,6 @@ static id GSLaunched(NSNotification *notification, BOOL active) } if ([lock tryLock] == NO) { - unsigned sleeps = 0; - /* * If the lock is really old ... assume the app has died and break it. */ @@ -256,8 +258,40 @@ static id GSLaunched(NSNotification *notification, BOOL active) { [file writeToFile: path atomically: YES]; } - [lock unlock]; + NS_DURING + { + sleeps = 0; + [lock unlock]; + } + NS_HANDLER + { + for (sleeps = 0; sleeps < 10; sleeps++) + { + NS_DURING + { + [lock unlock]; + NSLog(@"Unlocked %@", lock); + break; + } + NS_HANDLER + { + sleeps++; + if (sleeps >= 10) + { + NSLog(@"Unable to unlock %@", lock); + break; + } + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; + continue; + } + NS_ENDHANDLER; + } + } + NS_ENDHANDLER; + [mlock unlock]; // end critical section + [mlock release]; + if (active == YES) { NSString *activeName = [file objectForKey: @"GSActive"];