pool retain/release fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@37986 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2014-07-07 16:25:16 +00:00
parent 8faf0731ec
commit b05d9df931
2 changed files with 28 additions and 13 deletions

View file

@ -97,11 +97,8 @@
{
for (i = 0; i < count; i++)
{
if (YES == used[i])
{
[clients[i] _clearPool: self];
}
else
[clients[i] _clearPool: self];
if (NO == used[i])
{
[clients[i] release];
}
@ -260,6 +257,10 @@
}
u[found] = YES;
[lock unlockWithCondition: cond];
if (_debugging > 2)
{
NSLog(@"%@ provides %p", self, c[found]);
}
return [c[found] autorelease];
}
@ -340,11 +341,8 @@
while (max > maxConnections)
{
max--;
if (YES == u[max])
{
[c[max] _clearPool: self];
}
else
[c[max] _clearPool: self];
if (NO == u[max])
{
[c[max] release];
}
@ -416,11 +414,21 @@
if (YES == u[index] && client == c[index])
{
u[index] = NO;
[c[index] retain];
found = YES;
}
}
[self _unlock];
if (_debugging > 2)
{
if (YES == found)
{
NSLog(@"%@ swallows %p", self, client);
}
else
{
NSLog(@"%@ rejects %p", self, client);
}
}
return found;
}

View file

@ -75,15 +75,22 @@ main()
min: 1] autorelease];
#if 0
{
NSAutoreleasePool *p = [NSAutoreleasePool new];
NSAutoreleasePool *p;
SQLClient *c0;
SQLClient *c1;
[sp setDebugging: 2];
p = [NSAutoreleasePool new];
c0 = [sp provideClient];
c1 = [sp provideClient];
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 25.0]];
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]];
[p release];
p = [NSAutoreleasePool new];
c0 = [sp provideClient];
c1 = [sp provideClient];
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 15.0]];
[p release];
[sp provideClientBeforeDate: [NSDate dateWithTimeIntervalSinceNow: 25.0]];
}
#endif
db = [sp provideClient];