[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
DoubleCheckedLockingPatch
From: |
David Ayers |
Subject: |
DoubleCheckedLockingPatch |
Date: |
Wed, 11 Sep 2002 00:32:40 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 |
Hello Richard,
I stumbled over two double checked locking issues that should be fixed.
NSFileManager.m and GSLocal.m
Cheers,
Dave
Index: core/base/Source/GSLocale.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/GSLocale.m,v
retrieving revision 1.11
diff -u -r1.11 GSLocale.m
--- core/base/Source/GSLocale.m 20 Jun 2002 02:41:26 -0000 1.11
+++ core/base/Source/GSLocale.m 10 Sep 2002 21:33:32 -0000
@@ -196,7 +196,12 @@
}
[gnustep_global_lock lock];
- saved = [dict mutableCopy];
+ /* Another thread might have been faster in setting the static variable.
+ If so, we just drop our dict. */
+ if (saved == nil)
+ {
+ saved = [dict mutableCopy];
+ }
[gnustep_global_lock unlock];
return saved;
#else /* HAVE_LANGINFO_H */
Index: core/base/Source/NSFileManager.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSFileManager.m,v
retrieving revision 1.76
diff -u -r1.76 NSFileManager.m
--- core/base/Source/NSFileManager.m 22 Aug 2002 07:22:36 -0000 1.76
+++ core/base/Source/NSFileManager.m 10 Sep 2002 21:33:34 -0000
@@ -194,7 +194,10 @@
NS_DURING
{
[gnustep_global_lock lock];
- defaultManager = [[self alloc] init];
+ if (!defaultManager)
+ {
+ defaultManager = [[self alloc] init];
+ }
[gnustep_global_lock unlock];
}
NS_HANDLER
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- DoubleCheckedLockingPatch,
David Ayers <=