* Source/NSUserDefaults.m: Remove one of the locks in +userLanguages

to avoid a deadlock.
	Patch applied by: Gregory Casamento <greg.casamento@gmail.com>


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28504 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2009-08-21 17:44:39 +00:00
parent b753c64597
commit 54fdb742c3
2 changed files with 17 additions and 0 deletions

View file

@ -2,6 +2,12 @@
* Source/NSConnection.m: Joined split-line string constant * Source/NSConnection.m: Joined split-line string constant
2009-08-21 Doug Simons <dpsimons@testplant.com>
* Source/NSUserDefaults.m: Remove one of the locks in +userLanguages
to avoid a deadlock.
Patch applied by: Gregory Casamento <greg.casamento@gmail.com>
2009-08-21 Doug Simons <dpsimons@testplant.com> 2009-08-21 Doug Simons <dpsimons@testplant.com>
* Source/NSUserDefaults.m: Changes to bulletproof NSUserDefaults from * Source/NSUserDefaults.m: Changes to bulletproof NSUserDefaults from

View file

@ -486,6 +486,17 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
* +userLanguages uses this to rebuild language information and return it. * +userLanguages uses this to rebuild language information and return it.
*/ */
/* Return the sharedDefaults without locking in the simple case.
* We need to lock and check again before CREATING sharedDefaults if it doesn't exist,
* so that two threads can't create it at once (or call resetStandardUserDefaults at
* the same time).
* By not locking here, we avoid a deadlock that can occur between classLock and _lock. */
if (setSharedDefaults == YES)
{
IF_NO_GC([sharedDefaults retain];)
return AUTORELEASE(sharedDefaults);
}
[classLock lock]; [classLock lock];
/* /*