Author: rfm
Date: Wed Jun 10 10:05:59 2015
New Revision: 38608

URL: http://svn.gna.org/viewcvs/gnustep?rev=38608&view=rev
Log:
Try to manage count of connected clients better

Modified:
    libs/sqlclient/trunk/SQLClient.m

Modified: libs/sqlclient/trunk/SQLClient.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.m?rev=38608&r1=38607&r2=38608&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.m    (original)
+++ libs/sqlclient/trunk/SQLClient.m    Wed Jun 10 10:05:59 2015
@@ -926,27 +926,27 @@
   e = NSEnumerateHashTable(clientsHash);
   while (nil != (o = (SQLClient*)NSNextHashEnumeratorItem(&e)))
     {
-      if (since != nil)
-       {
-         NSTimeInterval        when = o->_lastOperation;
-
-          if (when < o->_lastStart)
+      if (YES == o->connected)
+        {
+          connectionCount++;
+          if (since != nil)
             {
-              when = o->_lastStart;
+              NSTimeInterval   when = o->_lastOperation;
+
+              if (when < o->_lastStart)
+                {
+                  when = o->_lastStart;
+                }
+              if (when < t)
+                {
+                  if (nil == a)
+                    {
+                      a = [NSMutableArray array];
+                    }
+                  [a addObject: o];
+                }
             }
-         if (when < t && YES == o->connected)
-           {
-              if (nil == a)
-                {
-                  a = [NSMutableArray array];
-                }
-              [a addObject: o];
-           }
-       }
-      else if ([o connected] == YES)
-       {
-         connectionCount++;
-       }
+        }
     }
   NSEndHashTableEnumeration(&e);
   [clientsLock unlock];
@@ -958,27 +958,30 @@
       o = [a lastObject];
       if ([o->lock tryLock])
         {
-         NSTimeInterval        when = o->_lastOperation;
-
-          if (when < o->_lastStart)
+         if (YES == o->connected)
             {
-              when = o->_lastStart;
+              NSTimeInterval   when = o->_lastOperation;
+
+              if (when < o->_lastStart)
+                {
+                  when = o->_lastStart;
+                }
+              if (when < t)
+                {
+                  NS_DURING
+                    {
+                      [o disconnect];
+                    }
+                  NS_HANDLER
+                    {
+                      NSLog(@"Problem disconnecting: %@", localException);
+                    }
+                  NS_ENDHANDLER
+                }
             }
-         if (when < t && YES == o->connected)
+          if (NO == o->connected)
             {
-              NS_DURING
-                {
-                  [o disconnect];
-                  if ([o connected] == YES)
-                    {
-                      connectionCount++;
-                    }
-                }
-              NS_HANDLER
-                {
-                  NSLog(@"Problem disconnecting: %@", localException);
-                }
-              NS_ENDHANDLER
+              connectionCount--;
             }
           [o->lock unlock];
         }


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

Reply via email to