mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Obscure thread-safety fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27209 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
61c03561d7
commit
b313d1b576
4 changed files with 30 additions and 10 deletions
|
@ -1,3 +1,12 @@
|
|||
2008-12-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSObjCRuntime.m: Fix minor thread-safety issue
|
||||
with behaviors ... lock the runtime while modifying method lists.
|
||||
* Source/NSDictionary.m: Fix initialisation order so that if two
|
||||
threads are initialising the cached class info should always be
|
||||
set up in the correct order.
|
||||
* Source/NSSet.m: ditto.
|
||||
|
||||
2008-12-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURL.m: Implement ipv6 addresses as per RFC2732
|
||||
|
|
|
@ -686,6 +686,8 @@ extern void class_add_method_list(Class, MethodList_t);
|
|||
|
||||
static Method_t search_for_method_in_class (Class cls, SEL op);
|
||||
|
||||
extern objc_mutex_t __objc_runtime_mutex;
|
||||
|
||||
void
|
||||
GSObjCAddMethods (Class cls, GSMethodList methods)
|
||||
{
|
||||
|
@ -697,6 +699,8 @@ GSObjCAddMethods (Class cls, GSMethodList methods)
|
|||
initialize_sel = sel_register_name ("initialize");
|
||||
}
|
||||
|
||||
objc_mutex_lock (__objc_runtime_mutex);
|
||||
|
||||
/* Add methods to class->dtable and class->methods */
|
||||
for (mlist = methods; mlist; mlist = mlist->method_next)
|
||||
{
|
||||
|
@ -754,12 +758,18 @@ GSObjCAddMethods (Class cls, GSMethodList methods)
|
|||
OBJC_FREE(new_list);
|
||||
}
|
||||
}
|
||||
objc_mutex_unlock (__objc_runtime_mutex);
|
||||
}
|
||||
|
||||
static Method_t
|
||||
search_for_method_in_class (Class cls, SEL op)
|
||||
{
|
||||
return cls != NULL ? search_for_method_in_list(cls->methods, op) : NULL;
|
||||
Method_t m;
|
||||
|
||||
objc_mutex_lock (__objc_runtime_mutex);
|
||||
m = cls != NULL ? search_for_method_in_list(cls->methods, op) : NULL;
|
||||
objc_mutex_unlock (__objc_runtime_mutex);
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif /* NeXT runtime */
|
||||
|
|
|
@ -108,18 +108,16 @@ static SEL appSel;
|
|||
{
|
||||
if (self == [NSDictionary class])
|
||||
{
|
||||
NSArray_class = [NSArray class];
|
||||
NSDictionaryClass = [NSDictionary class];
|
||||
NSMutableDictionaryClass = [NSMutableDictionary class];
|
||||
GSDictionaryClass = [GSDictionary class];
|
||||
GSMutableDictionaryClass = [GSMutableDictionary class];
|
||||
|
||||
eqSel = @selector(isEqual:);
|
||||
nxtSel = @selector(nextObject);
|
||||
objSel = @selector(objectForKey:);
|
||||
remSel = @selector(removeObjectForKey:);
|
||||
setSel = @selector(setObject:forKey:);
|
||||
appSel = @selector(appendString:);
|
||||
NSArray_class = [NSArray class];
|
||||
NSDictionaryClass = self;
|
||||
GSDictionaryClass = [GSDictionary class];
|
||||
[NSMutableDictionary class];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1123,6 +1121,8 @@ compareIt(id o1, id o2, void* context)
|
|||
{
|
||||
if (self == [NSMutableDictionary class])
|
||||
{
|
||||
NSMutableDictionaryClass = self;
|
||||
GSMutableDictionaryClass = [GSMutableDictionary class];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,9 @@ static Class NSMutableSet_concrete_class;
|
|||
{
|
||||
if (self == [NSSet class])
|
||||
{
|
||||
NSSet_abstract_class = [NSSet class];
|
||||
NSMutableSet_abstract_class = [NSMutableSet class];
|
||||
NSSet_abstract_class = self;
|
||||
NSSet_concrete_class = [GSSet class];
|
||||
NSMutableSet_concrete_class = [GSMutableSet class];
|
||||
[NSMutableSet class];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -915,6 +914,8 @@ static Class NSMutableSet_concrete_class;
|
|||
{
|
||||
if (self == [NSMutableSet class])
|
||||
{
|
||||
NSMutableSet_abstract_class = self;
|
||||
NSMutableSet_concrete_class = [GSMutableSet class];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue