mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-14 15:40:59 +00:00
Reinstate fix to avoid deadlock while purging pool
This commit is contained in:
parent
4c2a293640
commit
267987d01c
2 changed files with 17 additions and 8 deletions
|
@ -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>
|
2020-04-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Postgres.m: Change notification code to de-duplicate notifications
|
* Postgres.m: Change notification code to de-duplicate notifications
|
||||||
|
|
20
SQLClient.m
20
SQLClient.m
|
@ -2566,19 +2566,22 @@ static int poolConnections = 0;
|
||||||
|
|
||||||
- (oneway void) release
|
- (oneway void) release
|
||||||
{
|
{
|
||||||
/* We lock the table while checking, to prevent
|
/* We lock the table while checking, to prevent another thread
|
||||||
* another thread from grabbing this object while we are
|
* from grabbing this object while we are checking it.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
[clientsLock lock];
|
[clientsLock lock];
|
||||||
if (nil != _pool && [self retainCount] == 1)
|
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.
|
* 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
|
* wl 2019-05-01: The original implementation was calling this code
|
||||||
* when NSDecrementExtraRefCountWasZero returns YES, but
|
* when NSDecrementExtraRefCountWasZero returns YES, but
|
||||||
* this does not work with newer versions of the GNUstep
|
* 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
|
* Objective-C runtime, which both don't handle resurrection
|
||||||
* gracefully for objects whose retain count has become zero.
|
* gracefully for objects whose retain count has become zero.
|
||||||
*/
|
*/
|
||||||
|
[clientsLock unlock];
|
||||||
[_pool _swallowClient: self explicit: NO];
|
[_pool _swallowClient: self explicit: NO];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[super release];
|
[super release];
|
||||||
|
[clientsLock unlock];
|
||||||
}
|
}
|
||||||
[clientsLock unlock];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (SQLClientPool*) pool
|
- (SQLClientPool*) pool
|
||||||
|
|
Loading…
Reference in a new issue