Locking tidups/fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18016 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-11-01 07:09:12 +00:00
parent b5dd8fa367
commit 248f589502
3 changed files with 18 additions and 10 deletions

View file

@ -1,3 +1,11 @@
Sat Nov 01 07:05:00 2003 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNotificationCenter.m: Simplify locking code as original
code was hanging in GNUMail after Davids recent locking changes ...
not sure what the actual problem was, so this change may have merely
re-hidden a bug :-(
* Source/Additions/Unicode.m: Simplify to use non-recursive lock.
2003-10-31 David Ayers <d.ayers@inode.at> 2003-10-31 David Ayers <d.ayers@inode.at>
* Source/NSCharacterSet.m * Source/NSCharacterSet.m

View file

@ -893,7 +893,7 @@ static NSRecursiveLock *local_lock = nil;
@interface _GSLockInitializer : NSObject @interface _GSLockInitializer : NSObject
@end @end
@implementation _GSLockInitializer @implementation _GSLockInitializer
+ (void)initialize + (void) initialize
{ {
if (local_lock == nil) if (local_lock == nil)
{ {
@ -957,7 +957,7 @@ newLockAt(Class self, SEL _cmd, id *location)
* *
* </example> * </example>
*/ */
+ (id)newLockAt:(id *)location + (id) newLockAt: (id *)location
{ {
return newLockAt(self, _cmd, location); return newLockAt(self, _cmd, location);
} }
@ -987,7 +987,7 @@ newLockAt(Class self, SEL _cmd, id *location)
* *
* </example> * </example>
*/ */
+ (id)newLockAt:(id *)location + (id) newLockAt: (id *)location
{ {
return newLockAt(self, _cmd, location); return newLockAt(self, _cmd, location);
} }

View file

@ -122,7 +122,7 @@ internal_unicode_enc(void)
#endif #endif
static NSRecursiveLock *local_lock = nil; static GSLazyLock *local_lock = nil;
typedef unsigned char unc; typedef unsigned char unc;
static NSStringEncoding defEnc = GSUndefinedEncoding; static NSStringEncoding defEnc = GSUndefinedEncoding;
@ -210,7 +210,7 @@ static void GSSetupEncodingTable(void)
{ {
if (encodingTable == 0) if (encodingTable == 0)
{ {
[GS_INITIALIZED_LOCK(local_lock, GSLazyRecursiveLock) lock]; [GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (encodingTable == 0) if (encodingTable == 0)
{ {
static struct _strenc_ **encTable = 0; static struct _strenc_ **encTable = 0;
@ -328,7 +328,8 @@ GetAvailableEncodings()
{ {
if (_availableEncodings == 0) if (_availableEncodings == 0)
{ {
[GS_INITIALIZED_LOCK(local_lock, GSLazyRecursiveLock) lock]; GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (_availableEncodings == 0) if (_availableEncodings == 0)
{ {
NSStringEncoding *encodings; NSStringEncoding *encodings;
@ -342,7 +343,6 @@ GetAvailableEncodings()
* This is also the place where we determine the name we use * This is also the place where we determine the name we use
* for iconv to support unicode. * for iconv to support unicode.
*/ */
GSSetupEncodingTable();
encodings = objc_malloc(sizeof(NSStringEncoding) * (encTableSize+1)); encodings = objc_malloc(sizeof(NSStringEncoding) * (encTableSize+1));
pos = 0; pos = 0;
for (i = 0; i < encTableSize+1; i++) for (i = 0; i < encTableSize+1; i++)
@ -562,15 +562,15 @@ GetDefEncoding()
char *encoding; char *encoding;
unsigned int count; unsigned int count;
[GS_INITIALIZED_LOCK(local_lock, GSLazyRecursiveLock) lock]; GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
if (defEnc != GSUndefinedEncoding) if (defEnc != GSUndefinedEncoding)
{ {
[local_lock unlock]; [local_lock unlock];
return defEnc; return defEnc;
} }
GSSetupEncodingTable();
encoding = getenv("GNUSTEP_STRING_ENCODING"); encoding = getenv("GNUSTEP_STRING_ENCODING");
if (encoding != 0) if (encoding != 0)
{ {