Try to manage count of connected clients better

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@38608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-06-10 08:05:59 +00:00
parent 85d8389ba0
commit 11bf21a930

View file

@ -926,6 +926,9 @@ static int poolConnections = 0;
e = NSEnumerateHashTable(clientsHash);
while (nil != (o = (SQLClient*)NSNextHashEnumeratorItem(&e)))
{
if (YES == o->connected)
{
connectionCount++;
if (since != nil)
{
NSTimeInterval when = o->_lastOperation;
@ -934,7 +937,7 @@ static int poolConnections = 0;
{
when = o->_lastStart;
}
if (when < t && YES == o->connected)
if (when < t)
{
if (nil == a)
{
@ -943,9 +946,6 @@ static int poolConnections = 0;
[a addObject: o];
}
}
else if ([o connected] == YES)
{
connectionCount++;
}
}
NSEndHashTableEnumeration(&e);
@ -957,6 +957,8 @@ static int poolConnections = 0;
{
o = [a lastObject];
if ([o->lock tryLock])
{
if (YES == o->connected)
{
NSTimeInterval when = o->_lastOperation;
@ -964,15 +966,11 @@ static int poolConnections = 0;
{
when = o->_lastStart;
}
if (when < t && YES == o->connected)
if (when < t)
{
NS_DURING
{
[o disconnect];
if ([o connected] == YES)
{
connectionCount++;
}
}
NS_HANDLER
{
@ -980,6 +978,11 @@ static int poolConnections = 0;
}
NS_ENDHANDLER
}
}
if (NO == o->connected)
{
connectionCount--;
}
[o->lock unlock];
}
[a removeLastObject];