Author: rfm
Date: Tue Nov  3 11:20:31 2015
New Revision: 39133

URL: http://svn.gna.org/viewcvs/gnustep?rev=39133&view=rev
Log:
Add reporting of pool client retain counts

Modified:
    libs/sqlclient/trunk/SQLClient.h
    libs/sqlclient/trunk/SQLClientPool.m

Modified: libs/sqlclient/trunk/SQLClient.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.h?rev=39133&r1=39132&r2=39133&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.h    (original)
+++ libs/sqlclient/trunk/SQLClient.h    Tue Nov  3 11:20:31 2015
@@ -1845,7 +1845,7 @@
  * a group of merged transactions fails, it is then possible to attempt
  * to commit the individual transactions separately.<br />
  * NB. All transactions appended must be using the same database
- * connection (SQLClient instance).
+ * connection (SQLClient/SQLClientPool instance).
  */
 - (void) append: (SQLTransaction*)other;
 
@@ -1922,7 +1922,7 @@
 /**
  * Insert trn at the index'th position in the receiver.<br />
  * The transaction trn must be non-empty and must use the same
- * database client as the receiver.
+ * database client/pool as the receiver.
  */
 - (void) insertTransaction: (SQLTransaction*)trn atIndex: (unsigned)index;
 

Modified: libs/sqlclient/trunk/SQLClientPool.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClientPool.m?rev=39133&r1=39132&r2=39133&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClientPool.m        (original)
+++ libs/sqlclient/trunk/SQLClientPool.m        Tue Nov  3 11:20:31 2015
@@ -650,6 +650,7 @@
 {
   NSMutableArray        *idleInfo = nil;
   NSMutableArray        *liveInfo = nil;
+  NSMutableString       *retainInfo = nil;
   unsigned int          cond = 0;
   unsigned int          free = 0;
   unsigned int          dead = 0;
@@ -662,7 +663,8 @@
   [_lock lock];
   for (index = 0; index < _max; index++)
     {
-      SQLClient *client = _items[index].c;
+      SQLClient         *client = _items[index].c;
+      NSUInteger        rc = [client retainCount];
 
       /* Check to see if this client is free to be taken from the pool.
        * Also, if a client is connected but not in use, we call it idle.
@@ -682,8 +684,10 @@
                   liveInfo = [NSMutableArray array];
                 }
               [liveInfo addObject: [NSString stringWithFormat:
-                @"  Client '%@' active in transaction since %@\n",
-                [client name], d]];
+                @"  Client '%@' (retain count %"PRIuPTR
+                @") active in transaction since %@\n",
+                [client name], rc, d]];
+              rc = 0;
             }
           else
             {
@@ -706,8 +710,10 @@
                       idleInfo = [NSMutableArray array];
                     }
                   [idleInfo addObject: [NSString stringWithFormat:
-                    @"  Client '%@' taken from pool but idle since %@\n",
-                    [client name], d]];
+                    @"  Client '%@' (retain count %"PRIuPTR
+                    @") taken from pool but idle since %@\n",
+                    [client name], rc, d]];
+                  rc = 0;
                 }
               else
                 {
@@ -734,11 +740,24 @@
               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"];
+        }
     }
 
   s = [NSMutableString stringWithFormat: @" size min: %u, max: %u\n"
     @"live:%u, used:%u, idle:%u, free:%u, dead:%u\n",
     _min, _max, live, used, idle, free, dead];
+
   if (liveInfo)
     {
       for (index = 0; index < [liveInfo count]; index++)
@@ -752,6 +771,10 @@
         {
           [s appendString: [idleInfo objectAtIndex: index]];
         }
+    }
+  if (retainInfo)
+    {
+      [s appendString: retainInfo];
     }
   [_lock unlockWithCondition: cond];
   return s;


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to