Commit d83cb872 authored by Julien Muchembled's avatar Julien Muchembled

cache: fix possible endless loop in __repr__/_iterQueue

parent be839e92
...@@ -94,13 +94,16 @@ class ClientCache(object): ...@@ -94,13 +94,16 @@ class ClientCache(object):
def _iterQueue(self, level): def _iterQueue(self, level):
"""for debugging purpose""" """for debugging purpose"""
if level < len(self._queue_list): if level < len(self._queue_list):
item = head = self._queue_list[level] # Lockless iteration of the queue.
if item: # XXX: In case of race condition, the result is wrong but at least,
while 1: # it won't loop endlessly. If one want to collect accurate
# statistics, a lock should be used.
expire = 0
item = self._queue_list[level]
while item and item.level == level and expire < item.expire:
yield item yield item
expire = item.expire
item = item.next item = item.next
if item is head:
break
def _remove_from_oid_dict(self, item): def _remove_from_oid_dict(self, item):
item_list = self._oid_dict[item.oid] item_list = self._oid_dict[item.oid]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment