From 54fdb742c342eaac03e3af6a821b873a06c75a28 Mon Sep 17 00:00:00 2001 From: gcasa Date: Fri, 21 Aug 2009 17:44:39 +0000 Subject: [PATCH] * Source/NSUserDefaults.m: Remove one of the locks in +userLanguages to avoid a deadlock. Patch applied by: Gregory Casamento git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28504 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSUserDefaults.m | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0e39d25f4..e7d4e6481 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ * Source/NSConnection.m: Joined split-line string constant +2009-08-21 Doug Simons + + * Source/NSUserDefaults.m: Remove one of the locks in +userLanguages + to avoid a deadlock. + Patch applied by: Gregory Casamento + 2009-08-21 Doug Simons * Source/NSUserDefaults.m: Changes to bulletproof NSUserDefaults from diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 973c93447..75567cb68 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -486,6 +486,17 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ * +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]; /*