Просмотр исходного кода

don't leak DOs that fail to cache

Darren Ranalli 18 лет назад
Родитель
Сommit
fb964c3d16

+ 5 - 0
direct/src/distributed/CRCache.py

@@ -20,6 +20,7 @@ class CRCache:
         """
         assert self.checkCache()
         CRCache.notify.debug("Flushing the cache")
+        # NOTE: delayDeleted objects should no longer get into the cache in the first place
         # give objects a chance to clean themselves up before checking for DelayDelete leaks
         messenger.send('clientCleanup')
         # some of these objects might be holding delayDeletes on others
@@ -53,6 +54,7 @@ class CRCache:
         # Get the doId
         doId = distObj.getDoId()
         # Error check
+        success = False
         if self.dict.has_key(doId):
             CRCache.notify.warning("Double cache attempted for distObj "
                                    + str(doId))
@@ -64,6 +66,8 @@ class CRCache:
             self.fifo.append(distObj)
             self.dict[doId] = distObj
 
+            success = True
+
             if len(self.fifo) > self.maxCacheItems:
                 # if the cache is full, pop the oldest item
                 oldestDistObj = self.fifo.pop(0)
@@ -74,6 +78,7 @@ class CRCache:
 
         # Make sure that the fifo and the dictionary are sane
         assert len(self.dict) == len(self.fifo)
+        return success
 
     def retrieve(self, doId):
         assert self.checkCache()

+ 3 - 1
direct/src/distributed/ClientRepositoryBase.py

@@ -478,7 +478,9 @@ class ClientRepositoryBase(ConnectionRepository):
             # trivial objects that don't benefit from caching.
             # also don't try to cache an object that is delayDeleted
             if distObj.getCacheable() and distObj.getDelayDeleteCount() <= 0:
-                cache.cache(distObj)
+                cached = cache.cache(distObj)
+                if not cached:
+                    distObj.deleteOrDelay()
             else:
                 distObj.deleteOrDelay()