Thread safetly fix suggested by Wim

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23402 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-09-06 15:12:03 +00:00
parent b3f9244b29
commit ab1489c970
2 changed files with 13 additions and 0 deletions

View file

@ -1282,15 +1282,22 @@ static NSLock *cached_proxies_gate = nil;
/*
* If this would cause the connection to be deallocated then we
* must perform all necessary work (done in [-gcFinalize]).
*
* We bracket the code with a retain and release so that any
* retain/release pairs in the code won't cause recursion.
*
* We lock the connection table while checking, to prevent
* another thread from grabbing this connection while we are
* finalizing/deallocating it.
*/
M_LOCK(connection_table_gate);
if ([self retainCount] == 1)
{
[super retain];
[self gcFinalize];
[super release];
}
M_UNLOCK(connection_table_gate);
[super release];
}