Use standard locks rathere than obsolete lazy lock classes

This commit is contained in:
Richard Frith-Macdonald 2018-04-10 14:59:35 +01:00
parent 6c3d99ea3f
commit 3ced3237e8
17 changed files with 63 additions and 36 deletions

View file

@ -1,3 +1,30 @@
2018-04-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/Unicode.m:
* Source/GSHTTPAuthentication.m:
* Source/GSHTTPURLHandle.m:
* Source/GSMDNSNetServices.m:
* Source/GSURLPrivate.h:
* Source/NSCalendar.m:
* Source/NSCharacterSet.m:
* Source/NSConnection.m:
* Source/NSCountedSet.m:
* Source/NSIndexPath.m:
* Source/NSKeyValueObserving.m:
* Source/NSLocale.m:
* Source/NSMessagePort.m:
* Source/NSSocketPort.m:
* Source/NSUserDefaults.m:
* Source/NSValueTransformer.m:
Replace the obsolete GSLazyLock code with standard NSLocks now that
almost all significant software is multithreaded.
2018-04-10 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSThread.m: When adding a new thread, set the thread specific
memory to point to the object before doing anything else which might
attempt to access the thread (causing recursive registration).
2018-04-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/unicode/cop.h: Add comment/fixme

View file

@ -138,7 +138,7 @@ internal_unicode_enc(void)
#define UNICODE_UTF32 ""
#endif
static GSLazyLock *local_lock = nil;
static NSLock *local_lock = nil;
typedef unsigned char unc;
static NSStringEncoding defEnc = GSUndefinedEncoding;
@ -280,7 +280,7 @@ static void GSSetupEncodingTable(void)
{
if (encodingTable == 0)
{
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
[GS_INITIALIZED_LOCK(local_lock, NSLock) lock];
if (encodingTable == 0)
{
static struct _strenc_ **encTable = 0;
@ -2613,7 +2613,7 @@ GSPrivateAvailableEncodings()
if (_availableEncodings == 0)
{
GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
[GS_INITIALIZED_LOCK(local_lock, NSLock) lock];
if (_availableEncodings == 0)
{
NSStringEncoding *encodings;
@ -2776,7 +2776,7 @@ GSPrivateDefaultCStringEncoding()
GSSetupEncodingTable();
[GS_INITIALIZED_LOCK(local_lock, GSLazyLock) lock];
[GS_INITIALIZED_LOCK(local_lock, NSLock) lock];
if (defEnc != GSUndefinedEncoding)
{
[local_lock unlock];

View file

@ -37,7 +37,7 @@
static NSMutableDictionary *domainMap = nil;
static NSMutableSet *spaces = nil;
static NSMutableDictionary *store = nil;
static GSLazyLock *storeLock = nil;
static NSLock *storeLock = nil;
static GSMimeParser *mimeParser = nil;
@interface NSData(GSHTTPDigest)
@ -89,7 +89,7 @@ static GSMimeParser *mimeParser = nil;
[[NSObject leakAt: &domainMap] release];
store = [NSMutableDictionary new];
[[NSObject leakAt: &store] release];
storeLock = [GSLazyLock new];
storeLock = [NSLock new];
[[NSObject leakAt: &storeLock] release];
}
}
@ -632,7 +632,7 @@ static GSMimeParser *mimeParser = nil;
{
if ((self = [super init]) != nil)
{
self->_lock = [GSLazyLock new];
self->_lock = [NSLock new];
ASSIGN(self->_space, space);
ASSIGN(self->_credential, credential);
}

View file

@ -323,7 +323,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
[[NSObject leakAt: &urlCache] release];
urlOrder = [NSMutableArray new];
[[NSObject leakAt: &urlOrder] release];
urlLock = [GSLazyLock new];
urlLock = [NSLock new];
[[NSObject leakAt: &urlLock] release];
#if !defined(_WIN32)
sslClass = [NSFileHandle sslClass];

View file

@ -74,8 +74,8 @@
} while (0);
#if defined(_REENTRANT)
# define THE_LOCK GSLazyRecursiveLock *lock
# define CREATELOCK(x) x->lock = [GSLazyRecursiveLock new]
# define THE_LOCK NSRecursiveLock *lock
# define CREATELOCK(x) x->lock = [NSRecursiveLock new]
# define LOCK(x) [x->lock lock]
# define UNLOCK(x) [x->lock unlock]
# define DESTROYLOCK(x) DESTROY(x->lock)

View file

@ -78,10 +78,10 @@
/*
* Internal class for handling HTTP authentication
*/
@class GSLazyLock;
@class NSLock;
@interface GSHTTPAuthentication : NSObject
{
GSLazyLock *_lock;
NSLock *_lock;
NSURLCredential *_credential;
NSURLProtectionSpace *_space;
NSString *_nonce;

View file

@ -196,7 +196,7 @@ static NSRecursiveLock *classLock = nil;
+ (void) initialize
{
if (self == [NSLocale class])
classLock = [GSLazyRecursiveLock new];
classLock = [NSRecursiveLock new];
}
+ (void) defaultsDidChange: (NSNotification*)n

View file

@ -649,7 +649,7 @@ static Class concreteMutableClass = nil;
concreteClass = [NSBitmapCharSet class];
concreteMutableClass = [NSMutableBitmapCharSet class];
#endif
cache_lock = [GSLazyLock new];
cache_lock = [NSLock new];
[[NSObject leakAt: &cache_lock] release];
beenHere = YES;
}

View file

@ -365,7 +365,7 @@ static BOOL cacheCoders = NO;
static int debug_connection = 0;
static NSHashTable *connection_table;
static GSLazyRecursiveLock *connection_table_gate = nil;
static NSRecursiveLock *connection_table_gate = nil;
/*
* Locate an existing connection with the specified send and receive ports.
@ -665,17 +665,17 @@ static NSLock *cached_proxies_gate = nil;
if (connection_table_gate == nil)
{
connection_table_gate = [GSLazyRecursiveLock new];
connection_table_gate = [NSRecursiveLock new];
[[NSObject leakAt: &connection_table_gate] release];
}
if (cached_proxies_gate == nil)
{
cached_proxies_gate = [GSLazyLock new];
cached_proxies_gate = [NSLock new];
[[NSObject leakAt: &cached_proxies_gate] release];
}
if (root_object_map_gate == nil)
{
root_object_map_gate = [GSLazyLock new];
root_object_map_gate = [NSLock new];
[[NSObject leakAt: &root_object_map_gate] release];
}
@ -1093,7 +1093,7 @@ static NSLock *cached_proxies_gate = nil;
IrequestDepth = 0;
Idelegate = nil;
IrefGate = [GSLazyRecursiveLock new];
IrefGate = [NSRecursiveLock new];
/*
* Some attributes are inherited from the parent if possible.

View file

@ -42,7 +42,7 @@
/*
* Class variables for uniquing objects;
*/
static GSLazyRecursiveLock *uniqueLock = nil;
static NSRecursiveLock *uniqueLock = nil;
static NSCountedSet *uniqueSet = nil;
static IMP uniqueImp = 0;
static IMP lockImp = 0;
@ -72,7 +72,7 @@ static Class NSCountedSet_concrete_class;
{
NSCountedSet_abstract_class = self;
NSCountedSet_concrete_class = [GSCountedSet class];
uniqueLock = [GSLazyRecursiveLock new];
uniqueLock = [NSRecursiveLock new];
[[NSObject leakAt: &uniqueLock] release];
lockImp = [uniqueLock methodForSelector: @selector(lock)];
unlockImp = [uniqueLock methodForSelector: @selector(unlock)];

View file

@ -34,7 +34,7 @@
#import "Foundation/NSLock.h"
#import "GNUstepBase/GSLock.h"
static GSLazyRecursiveLock *lock = nil;
static NSRecursiveLock *lock = nil;
static NSHashTable *shared = 0;
static Class myClass = 0;
static NSIndexPath *empty = nil;
@ -76,7 +76,7 @@ static NSIndexPath *dummy = nil;
shared = NSCreateHashTable(NSNonRetainedObjectHashCallBacks, 1024);
[[NSObject leakAt: &shared] release];
NSHashInsert(shared, empty);
lock = [GSLazyRecursiveLock new];
lock = [NSRecursiveLock new];
[[NSObject leakAt: &lock] release];
}
}

View file

@ -88,7 +88,7 @@ setup()
[gnustep_global_lock lock];
if (nil == kvoLock)
{
kvoLock = [GSLazyRecursiveLock new];
kvoLock = [NSRecursiveLock new];
null = [[NSNull null] retain];
classTable = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 128);
@ -177,7 +177,7 @@ setup()
@interface GSKVOInfo : NSObject
{
NSObject *instance; // Not retained.
GSLazyRecursiveLock *iLock;
NSRecursiveLock *iLock;
NSMapTable *paths;
}
- (GSKVOPathInfo *) lockReturningPathInfoForKey: (NSString *)key;
@ -1209,7 +1209,7 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
instance = i;
paths = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, 8);
iLock = [GSLazyRecursiveLock new];
iLock = [NSRecursiveLock new];
return self;
}

View file

@ -204,7 +204,7 @@ static NSRecursiveLock *classLock = nil;
{
if (self == [NSLocale class])
{
classLock = [GSLazyRecursiveLock new];
classLock = [NSRecursiveLock new];
[[NSObject leakAt: &classLock] release];
allLocales = [[NSMutableDictionary alloc] initWithCapacity: 0];
[[NSObject leakAt: &allLocales] release];

View file

@ -329,7 +329,7 @@ static Class runLoopClass;
handle = (GSMessageHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
handle->desc = d;
handle->wMsgs = [NSMutableArray new];
handle->myLock = [GSLazyRecursiveLock new];
handle->myLock = [NSRecursiveLock new];
handle->valid = YES;
return AUTORELEASE(handle);
}
@ -1153,7 +1153,7 @@ typedef struct {
messagePortMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);
messagePortLock = [GSLazyRecursiveLock new];
messagePortLock = [NSRecursiveLock new];
/* It's possible that an old process, with the same process ID as
* this one, got forcibly killed or crashed so that clean_up_sockets
@ -1265,7 +1265,7 @@ typedef struct {
((internal*)(port->_internal))->_handles
= NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
((internal*)(port->_internal))->_myLock = [GSLazyRecursiveLock new];
((internal*)(port->_internal))->_myLock = [NSRecursiveLock new];
port->_is_valid = YES;
if (shouldListen == YES)

View file

@ -424,7 +424,7 @@ static Class runLoopClass;
handle = (GSTcpHandle*)NSAllocateObject(self, 0, NSDefaultMallocZone());
handle->desc = d;
handle->wMsgs = [NSMutableArray new];
handle->myLock = [GSLazyRecursiveLock new];
handle->myLock = [NSRecursiveLock new];
#if defined(_WIN32)
ev = (WSAEVENT)CreateEvent(NULL,NO,NO,NULL);
if (ev == WSA_INVALID_EVENT)
@ -1452,7 +1452,7 @@ static Class tcpPortClass;
tcpPortMap = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
[[NSObject leakAt: &tcpPortMap] release];
tcpPortLock = [GSLazyRecursiveLock new];
tcpPortLock = [NSRecursiveLock new];
[[NSObject leakAt: &tcpPortLock] release];
}
}
@ -1554,7 +1554,7 @@ static Class tcpPortClass;
port->events = NSCreateMapTable(NSIntegerMapKeyCallBacks,
NSIntegerMapValueCallBacks, 0);
#endif
port->myLock = [GSLazyRecursiveLock new];
port->myLock = [NSRecursiveLock new];
port->_is_valid = YES;
if (shouldListen == YES && [thisHost isEqual: aHost])

View file

@ -1161,7 +1161,7 @@ newLanguages(NSArray *oldNames)
}
}
_lock = [GSLazyRecursiveLock new];
_lock = [NSRecursiveLock new];
if (YES == [self _readOnly])
{

View file

@ -52,7 +52,7 @@
// non-abstract methods
static NSMutableDictionary *registry = nil;
static GSLazyLock *lock = nil;
static NSLock *lock = nil;
+ (void) initialize
{
@ -60,7 +60,7 @@ static GSLazyLock *lock = nil;
{
NSValueTransformer *t;
lock = [GSLazyLock new];
lock = [NSLock new];
[[NSObject leakAt: &lock] release];
registry = [[NSMutableDictionary alloc] init];
[[NSObject leakAt: &registry] release];