changeset 1836:42fb37416fe8

fix race condition for ItemCache.news
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 27 Feb 2007 11:21:27 +0100
parents af0feb0e3c7b
children ddfd8d5fa282
files MoinMoin/Page.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Mon Feb 26 00:09:20 2007 +0100
+++ b/MoinMoin/Page.py	Tue Feb 27 11:21:27 2007 +0100
@@ -34,7 +34,8 @@
         """
         self.name = name
         self.cache = {}
-        self.log_pos = None
+        self.log_pos = None # TODO: initialize this to EOF pos of log
+                            # to avoid reading in the whole log on first request
         self.requests = 0
         self.hits = 0
 
@@ -81,7 +82,8 @@
         """
         from MoinMoin.logfile import editlog
         elog = editlog.EditLog(request)
-        self.log_pos, items = elog.news(self.log_pos)
+        old_pos = self.log_pos
+        new_pos, items = elog.news(old_pos)
         if items:
             if self.name == 'meta':
                 for item in items:
@@ -93,6 +95,8 @@
             elif self.name == 'pagelists':
                 logging.debug("cache: clearing pagelist cache")
                 self.cache = {}
+        self.log_pos = new_pos # important to do this at the end -
+                               # avoids threading race conditions
 
 
 class Page: