changes to avoid deadlock

This commit is contained in:
Richard Frith-Macdonald 2020-02-25 11:21:11 +00:00
parent fea9797591
commit a9588e8073
2 changed files with 16 additions and 8 deletions

View file

@ -1,3 +1,7 @@
2020-02-25 Richard Frith-Macdonald <rfm@gnu.org>
* SQLClient.m: Changes t -release to avoid deadlock purging pool.
2020-02-14 Richard Frith-Macdonald <rfm@gnu.org>
* SQLClient.m: Re-implement SQLString as a true subclass rather than

View file

@ -2484,19 +2484,22 @@ static int poolConnections = 0;
- (oneway void) release
{
/* We lock the table while checking, to prevent
* another thread from grabbing this object while we are
* checking it.
* If we are going to deallocate the object, we first remove
* it from the table so that no other thread will find it
* and try to use it while it is being deallocated.
/* We lock the table while checking, to prevent another thread
* from grabbing this object while we are checking it.
*/
[clientsLock lock];
if (nil != _pool && [self retainCount] == 1)
{
/* If this is the only reference to a client associated with
/* This is the only reference to a client associated with
* a connection pool we put this client back to the pool.
*
* That being the case, we know that this thread 'owns'
* the client and it's not going to be deallocated and not
* going to have the _pool iinstance variable changed, so it
* is safe to unlock clientsLock before returning the client
* to the pool. This avoids a possible deadlock when a pool
* is being purged.
*
* wl 2019-05-01: The original implementation was calling this code
* when NSDecrementExtraRefCountWasZero returns YES, but
* this does not work with newer versions of the GNUstep
@ -2504,13 +2507,14 @@ static int poolConnections = 0;
* Objective-C runtime, which both don't handle resurrection
* gracefully for objects whose retain count has become zero.
*/
[clientsLock unlock];
[_pool _swallowClient: self explicit: NO];
}
else
{
[super release];
[clientsLock unlock];
}
[clientsLock unlock];
}
- (SQLClientPool*) pool