Reinstate fix to avoid deadlock while purging pool

This commit is contained in:
Wolfgang Lux 2020-09-01 15:24:16 +02:00
parent 4c2a293640
commit 267987d01c
2 changed files with 17 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2020-09-01 Wolfgang Lux <wolfgang.lux@gmail.com>
* SQLClient.m (release): Reinstate fix to avoid deadlock while
purging pool.
2020-04-21 Richard Frith-Macdonald <rfm@gnu.org>
* Postgres.m: Change notification code to de-duplicate notifications

View file

@ -2566,19 +2566,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
@ -2586,13 +2589,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