Author: rfm
Date: Wed Nov 4 10:30:36 2015
New Revision: 39141
URL: http://svn.gna.org/viewcvs/gnustep?rev=39141&view=rev
Log:
improve diagnostics
Modified:
libs/sqlclient/trunk/SQLClientPool.m
Modified: libs/sqlclient/trunk/SQLClientPool.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClientPool.m?rev=39141&r1=39140&r2=39141&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClientPool.m (original)
+++ libs/sqlclient/trunk/SQLClientPool.m Wed Nov 4 10:30:36 2015
@@ -70,6 +70,7 @@
@implementation SQLClientPool
+#if defined(GNUSTEP)
static Class cls = Nil;
+ (void) initialize
@@ -79,6 +80,7 @@
cls = [NSAutoreleasePool class];
}
}
+#endif
- (int) availableConnections
{
@@ -580,6 +582,7 @@
{
[_items[_max].c release];
}
+ DESTROY(_items[_max].o);
}
_items = realloc(_items, maxConnections * sizeof(SQLClientPoolItem));
}
@@ -682,25 +685,27 @@
*/
if (uc > 0)
{
- NSUInteger ac;
- NSString *s;
-
- ac = [cls autoreleaseCountForObject: client];
+ NSString *tmp;
+
if (NSNotFound == uc)
{
- s = [NSString stringWithFormat: @" Client '%@'"
- @" provided exclusively (retained:%llu - autoreleased:%llu)",
- [client name],
- (unsigned long long)rc, (unsigned long long)ac];
+ tmp = [NSString stringWithFormat: @" Client '%@'"
+ @" provided exclusively (retained:%"PRIuPTR,
+ [client name], rc];
}
else
{
- s = [NSString stringWithFormat: @" Client '%@'"
- @" provided %lld time%s (retained:%llu - autoreleased:%llu)",
- [client name],
- (unsigned long long)uc, (1 == uc) ? "" : "s",
- (unsigned long long)rc, (unsigned long long)ac];
- }
+ tmp = [NSString stringWithFormat: @" Client '%@'"
+ @" provided %"PRIuPTR
+ @" time%s (retained:%"PRIuPTR,
+ [client name], uc, ((1 == uc) ? "" : "s"), rc];
+ }
+
+#if defined(GNUSTEP)
+ NSUInteger ac = [cls autoreleaseCountForObject: client];
+
+ tmp = [tmp stringByAppendingFormat: @" - autoreleased:%"PRIuPTR, ac];
+#endif
/* This is a client which has been provided by the pool,
* so it is in use by some code.
@@ -714,8 +719,8 @@
{
liveInfo = [NSMutableArray array];
}
- [liveInfo addObject: [s stringByAppendingFormat:
- @" active in transaction since %@\n", d]];
+ [liveInfo addObject: [tmp stringByAppendingFormat:
+ @") active in transaction since %@\n", d]];
rc = 0;
}
else
@@ -738,24 +743,36 @@
{
idleInfo = [NSMutableArray array];
}
- [idleInfo addObject: [s stringByAppendingFormat:
- @" taken from pool but idle since %@\n", d]];
+ [idleInfo addObject: [tmp stringByAppendingFormat:
+ @") taken from pool but idle since %@\n", d]];
}
else
{
idle++;
- [idleInfo addObject: [s stringByAppendingFormat:
- @" taken from pool and recently used\n"]];
+ [idleInfo addObject: [tmp stringByAppendingFormat:
+ @") taken from pool and recently used\n"]];
}
}
}
else
{
+ BOOL connected = [_items[index].c connected];
+
/* The client is not in use and can be provided by the pool,
* so we must therefore re-lock with condition 1.
*/
cond = 1;
- if (YES == [_items[index].c connected])
+ if (nil == retainInfo)
+ {
+ retainInfo = [NSMutableString stringWithCapacity: 100];
+ }
+ [retainInfo appendFormat:
+ @" Client '%@' (retain count %"PRIuPTR
+ @") %s pool %s connected to server\n",
+ [client name], rc,
+ ((_items[index].u > 0) ? "taken from" : "available in"),
+ ((YES == connected) ? "and" : "but not")];
+ if (YES == connected)
{
/* Still connected, so we count it as a free connection.
*/
@@ -766,18 +783,6 @@
/* Not connected, so we count it as a dead connection.
*/
dead++;
- }
- if (rc > 1)
- {
- if (nil == retainInfo)
- {
- retainInfo = [NSMutableString stringWithCapacity: 100];
- }
- [retainInfo appendFormat:
- @" Client '%@' (retain count %"PRIuPTR
- @") %s pool\n",
- [client name], rc,
- (_items[index].u > 0) ? "taken from" : "available in"];
}
}
}
@@ -942,8 +947,8 @@
NSUInteger uc;
int index;
- rc = (unsigned long)[o retainCount];
- ac = (unsigned long)[cls autoreleaseCountForObject: o];
+ rc = [o retainCount];
+ ac = [cls autoreleaseCountForObject: o];
[_lock lock];
uc = 0;
for (index = 0; index < _max; index++)
@@ -958,15 +963,19 @@
if (NSNotFound == uc)
{
return [NSString stringWithFormat:
- @" provided exclusively (retained:%llu - autoreleased:%llu)",
- (unsigned long long)rc, (unsigned long long)ac];
+ @" provided exclusively (retained:%"PRIuPTR
+ @" - autoreleased:%"PRIuPTR
+ @")",
+ rc, ac];
}
else
{
return [NSString stringWithFormat:
- @" provided %lld time%s (retained:%llu - autoreleased:%llu)",
- (unsigned long long)uc, (1 == uc) ? "" : "s",
- (unsigned long long)rc, (unsigned long long)ac];
+ @" provided %"PRIuPTR
+ @" time%s (retained:%"PRIuPTR
+ @" - autoreleased:%"PRIuPTR
+ @")",
+ uc, ((1 == uc) ? "" : "s"), rc, ac];
}
}
#endif
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs