diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m index 8ea861c00..6cdfafd24 100644 --- a/Source/GSTcpPort.m +++ b/Source/GSTcpPort.m @@ -999,19 +999,16 @@ static Class runLoopClass; static NSRecursiveLock *tcpPortLock = nil; static NSMapTable *tcpPortMap = 0; +static Class tcpPortClass; + (void) initialize { - if (tcpPortLock == nil) + if (self == [GSTcpPort class]) { - [gnustep_global_lock lock]; - if (tcpPortLock == nil) - { - tcpPortLock = [NSRecursiveLock new]; - tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks, - NSNonOwnedPointerMapValueCallBacks, 0); - } - [gnustep_global_lock unlock]; + tcpPortClass = self; + tcpPortLock = [NSRecursiveLock new]; + tcpPortMap = NSCreateMapTable(NSIntMapKeyCallBacks, + NSNonOwnedPointerMapValueCallBacks, 0); } } @@ -1414,7 +1411,7 @@ static NSMapTable *tcpPortMap = 0; - (id) init { RELEASE(self); - self = [GSTcpPort new]; + self = [tcpPortClass new]; return self; } @@ -1574,8 +1571,12 @@ static NSMapTable *tcpPortMap = 0; { BOOL sent = NO; GSTcpHandle *h; - unsigned rl = [self reservedSpaceLength]; + unsigned rl; + if ([self isValid] == NO) + { + return NO; + } if ([components count] == 0) { NSLog(@"empty components sent"); @@ -1586,12 +1587,13 @@ static NSMapTable *tcpPortMap = 0; * fail, unless it's zero, in which case we can insert a data object for * the header. */ + rl = [self reservedSpaceLength]; if (length != 0 && length != rl) { NSLog(@"bad reserved length - %u", length); return NO; } - if ([receivingPort isKindOfClass: [GSTcpPort class]] == NO) + if ([receivingPort isKindOfClass: tcpPortClass] == NO) { NSLog(@"woah there - receiving port is not the correct type"); return NO; @@ -1688,7 +1690,7 @@ static NSMapTable *tcpPortMap = 0; RELEASE(d); } } - else if ([o isKindOfClass: [GSTcpPort class]]) + else if ([o isKindOfClass: tcpPortClass]) { NSData *d = newDataWithEncodedPort(o); unsigned dLength = [d length]; diff --git a/Source/NSConnection.m b/Source/NSConnection.m index 2a46d701b..aed1d685f 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -811,7 +811,7 @@ static NSLock *global_proxies_gate; M_UNLOCK(_refGate); return; } - + _isValid = NO; M_LOCK(connection_table_gate); NSHashRemove(connection_table, self); [timer invalidate]; @@ -865,16 +865,6 @@ static NSLock *global_proxies_gate; * might otherwise de deallocated. */ M_LOCK(_proxiesGate); - if (_remoteProxies != 0) - { - NSFreeMapTable(_remoteProxies); - _remoteProxies = 0; - } - if (_localObjects != 0) - { - NSFreeMapTable(_localObjects); - _localObjects = 0; - } if (_localTargets != 0) { NSArray *targets; @@ -893,6 +883,16 @@ static NSLock *global_proxies_gate; NSFreeMapTable(_localTargets); _localTargets = 0; } + if (_remoteProxies != 0) + { + NSFreeMapTable(_remoteProxies); + _remoteProxies = 0; + } + if (_localObjects != 0) + { + NSFreeMapTable(_localObjects); + _localObjects = 0; + } M_UNLOCK(_proxiesGate); RELEASE(self);