Minor bugfix patch

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-09-30 17:47:35 +00:00
parent ce828f5acf
commit d0315f7662
3 changed files with 33 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2003-09-30 Derek Zhou <dzhou@chrontel.com>
* Source/NSCharacterSet.m: patch to ensure lock is created as
soon as the process goes multi-threaded, therefore avoiding
a race condition causing a rare exception.
2003-09-26 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSString.m: Fix pathExtension bug reported by Roland

View file

@ -3377,6 +3377,7 @@ static NSCharacterSet *tokenSet = nil;
/**
* Search the content of this document to locate a part whose content ID
* matches the specified key. Recursively descend into other documents.<br />
* Wraps the supplied key in angle brackets if they are not present.<br />
* Return nil if no match is found, the matching GSMimeDocument otherwise.
*/
- (id) contentByID: (NSString*)key

View file

@ -33,6 +33,8 @@
#include "Foundation/NSLock.h"
#include "Foundation/NSPathUtilities.h"
#include "Foundation/NSDictionary.h"
#include "Foundation/NSThread.h"
#include "Foundation/NSNotification.h"
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
@ -43,6 +45,18 @@ static NSLock* cache_lock = nil;
@implementation NSCharacterSet
+ (void) _becomeThreaded: (NSNotification*)notification
{
if (cache_lock == nil)
{
cache_lock = [NSLock new];
[[NSNotificationCenter defaultCenter]
removeObserver: self
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
+ (void) initialize
{
static BOOL one_time = NO;
@ -57,6 +71,18 @@ static NSLock* cache_lock = nil;
}
one_time = YES;
}
if ([NSThread isMultiThreaded])
{
[self _becomeThreaded: nil];
}
else
{
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_becomeThreaded:)
name: NSWillBecomeMultiThreadedNotification
object: nil];
}
}
/* Provide a default object for allocation */
@ -73,8 +99,6 @@ static NSLock* cache_lock = nil;
NSString *set_path;
NSBundle *bundle;
if (!cache_lock)
cache_lock = [NSLock new];
[cache_lock lock];
set = nil; /* Quiet warnings */