Author: rfm
Date: Fri Jul  4 15:56:29 2014
New Revision: 37981

URL: http://svn.gna.org/viewcvs/gnustep?rev=37981&view=rev
Log:
try to close unwanted connections whenever we end any operation which locks
the pool.

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=37981&r1=37980&r2=37981&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.h    (original)
+++ libs/sqlclient/trunk/SQLClient.h    Fri Jul  4 15:56:29 2014
@@ -378,7 +378,6 @@
    * This should only be modified by the -setShouldTrim: method.
    */
   BOOL                  _shouldTrim;    /** Should whitespace be trimmed? */
-  BOOL                  _forUseInPool;  /** Should be used in a pool only */
   NSString             *_name;         /** Unique identifier for instance */
   NSString             *_client;       /** Identifier within backend */
   NSString             *_database;     /** The configured database name/host */

Modified: libs/sqlclient/trunk/SQLClientPool.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClientPool.m?rev=37981&r1=37980&r2=37981&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClientPool.m        (original)
+++ libs/sqlclient/trunk/SQLClientPool.m        Fri Jul  4 15:56:29 2014
@@ -380,21 +380,40 @@
 - (BOOL) swallowClient: (SQLClient*)client
 {
   BOOL  found = NO;
+  int   index;
+
+  [self _lock];
+  for (index = 0; index < max && NO == found; index++)
+    {
+      if (YES == u[index] && client == c[index])
+        {
+          u[index] = NO;
+          [c[index] retain];
+          found = YES;
+        }
+    }
+  [self _unlock];
+  return found;
+}
+
+@end
+
+@implementation SQLClientPool (Private)
+
+- (void) _lock
+{
+  [lock lock];
+}
+
+- (void) _unlock
+{
   int   idle = 0;
   int   used = 0;
   int   cond = 0;
   int   index;
 
-  [self _lock];
   for (index = 0; index < max; index++)
     {
-      if (YES == u[index] && client == c[index])
-        {
-          u[index] = NO;
-          [c[index] retain];
-          found = YES;
-        }
-
       /* 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.
        */
@@ -447,32 +466,7 @@
       idle--;
     }
   [lock unlockWithCondition: cond];
-  return found;
 }
 
 @end
 
-@implementation SQLClientPool (Private)
-
-- (void) _lock
-{
-  [lock lock];
-}
-
-- (void) _unlock
-{
-  int   index;
-
-  for (index = 0; index < max; index++)
-    {
-      if (NO == u[index])
-        {
-          [lock unlockWithCondition: 1];
-          return;
-        }
-    }
-  [lock unlockWithCondition: 0];
-}
-
-@end
-


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

Reply via email to