[CalendarServer-changes] [15607] twext/trunk/twext/who/ldap/_service.py

source_changes at macosforge.org source_changes at macosforge.org
Thu May 19 09:07:14 PDT 2016


Revision: 15607
          http://trac.calendarserver.org//changeset/15607
Author:   sagen at apple.com
Date:     2016-05-19 09:07:14 -0700 (Thu, 19 May 2016)
Log Message:
-----------
Compute activeCount from the actual data structures rather than maintaining a counter

Modified Paths:
--------------
    twext/trunk/twext/who/ldap/_service.py

Modified: twext/trunk/twext/who/ldap/_service.py
===================================================================
--- twext/trunk/twext/who/ldap/_service.py	2016-05-19 00:55:46 UTC (rev 15606)
+++ twext/trunk/twext/who/ldap/_service.py	2016-05-19 16:07:14 UTC (rev 15607)
@@ -443,7 +443,7 @@
         )
 
         self.poolStats[connectionID] += 1
-        self.activeCount += 1
+        self.activeCount = len(self.connections) - self.connectionQueue.qsize()
         self.poolStats["connection-active"] = self.activeCount
         self.poolStats["connection-max"] = max(
             self.poolStats["connection-max"], self.activeCount
@@ -461,8 +461,8 @@
         """
         A connection is no longer needed - return it to the pool.
         """
-        self.activeCount -= 1
         self.connectionQueue.put(connection)
+        self.activeCount = len(self.connections) - self.connectionQueue.qsize()
 
 
     def _failedConnection(self, connection):
@@ -470,9 +470,9 @@
         A connection has failed; remove it from the list of active connections.
         A new one will be created if needed.
         """
-        self.activeCount -= 1
         self.poolStats["connection-errors"] += 1
         self.connections.remove(connection)
+        self.activeCount = len(self.connections) - self.connectionQueue.qsize()
 
 
     def _connect(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160519/2e39abfe/attachment-0001.html>


More information about the calendarserver-changes mailing list