Explorar el Código

3.0a6: fix rotating file logger race condition (branched from 3.0a5 as opposed to HEAD due to untested changes on the HEAD).

Chris McDonough hace 17 años
padre
commit
28a3d31023
Se han modificado 3 ficheros con 20 adiciones y 3 borrados
  1. 7 0
      CHANGES.txt
  2. 12 2
      src/supervisor/loggers.py
  3. 1 1
      src/supervisor/version.txt

+ 7 - 0
CHANGES.txt

@@ -1,3 +1,10 @@
+3.0a6
+
+  - The RotatingFileLogger had a race condition in its doRollover
+    method whereby a file might not actually exist despite a call to
+    os.path.exists on the line above a place where we try to remove
+    it.  We catch the exception now and ignore the missing file.
+
 3.0a5
 3.0a5
 
 
   - Supervisorctl now supports persistent readline history.  To
   - Supervisorctl now supports persistent readline history.  To

+ 12 - 2
src/supervisor/loggers.py

@@ -210,11 +210,21 @@ class RotatingFileHandler(FileHandler):
                 dfn = "%s.%d" % (self.baseFilename, i + 1)
                 dfn = "%s.%d" % (self.baseFilename, i + 1)
                 if os.path.exists(sfn):
                 if os.path.exists(sfn):
                     if os.path.exists(dfn):
                     if os.path.exists(dfn):
-                        os.remove(dfn)
+                        try:
+                            os.remove(dfn)
+                        except OSError, why:
+                            # catch race condition (already deleted)
+                            if why[0] != errno.ENOENT:
+                                raise
                     os.rename(sfn, dfn)
                     os.rename(sfn, dfn)
             dfn = self.baseFilename + ".1"
             dfn = self.baseFilename + ".1"
             if os.path.exists(dfn):
             if os.path.exists(dfn):
-                os.remove(dfn)
+                try:
+                    os.remove(dfn)
+                except OSError, why:
+                    # catch race condition (already deleted)
+                    if why[0] != errno.ENOENT:
+                        raise
             os.rename(self.baseFilename, dfn)
             os.rename(self.baseFilename, dfn)
         self.stream = open(self.baseFilename, 'w')
         self.stream = open(self.baseFilename, 'w')
 
 

+ 1 - 1
src/supervisor/version.txt

@@ -1,2 +1,2 @@
-3.0a5
+3.0a6