@ -57,7 +57,7 @@ class FilterPoll(FileFilter):
FileFilter . __init__ ( self , jail )
FileFilter . __init__ ( self , jail )
self . __modified = False
self . __modified = False
## The time of the last modification of the file.
## The time of the last modification of the file.
self . __ lastModTime = dict ( )
self . __ prevStats = dict ( )
self . __file404Cnt = dict ( )
self . __file404Cnt = dict ( )
logSys . debug ( " Created FilterPoll " )
logSys . debug ( " Created FilterPoll " )
@ -67,7 +67,7 @@ class FilterPoll(FileFilter):
# @param path log file path
# @param path log file path
def _addLogPath ( self , path ) :
def _addLogPath ( self , path ) :
self . __ lastModTime[ path ] = 0
self . __ prevStats[ path ] = ( 0 , None , None ) # mtime, ino, size
self . __file404Cnt [ path ] = 0
self . __file404Cnt [ path ] = 0
##
##
@ -76,7 +76,7 @@ class FilterPoll(FileFilter):
# @param path the log file to delete
# @param path the log file to delete
def _delLogPath ( self , path ) :
def _delLogPath ( self , path ) :
del self . __ lastModTime [ path ]
del self . __ prevStats [ path ]
del self . __file404Cnt [ path ]
del self . __file404Cnt [ path ]
##
##
@ -126,18 +126,20 @@ class FilterPoll(FileFilter):
def isModified ( self , filename ) :
def isModified ( self , filename ) :
try :
try :
logStats = os . stat ( filename )
logStats = os . stat ( filename )
stats = logStats . st_mtime , logStats . st_ino , logStats . st_size
pstats = self . __prevStats [ filename ]
self . __file404Cnt [ filename ] = 0
self . __file404Cnt [ filename ] = 0
if logSys . getEffectiveLevel ( ) < = 7 :
if logSys . getEffectiveLevel ( ) < = 7 :
# we do not want to waste time on strftime etc if not necessary
# we do not want to waste time on strftime etc if not necessary
dt = logStats . st_mtime - self . __lastModTime [ filename ]
dt = logStats . st_mtime - pstats [ 0 ]
logSys . log ( 7 , " Checking %s for being modified. Previous/current mtime s: %s / %s . dt: %s " ,
logSys . log ( 7 , " Checking %s for being modified. Previous/current stat s: %s / %s . dt: %s " ,
filename , _ctime( self . __lastModTime [ filename ] ) , _ctime ( logStats . st_mtime ) , dt )
filename , pstats, stats , dt )
# os.system("stat %s | grep Modify" % filename)
# os.system("stat %s | grep Modify" % filename)
if self . __lastModTime [ filename ] == logStats . st_mtime :
if pstats == stats :
return False
return False
else :
else :
logSys . debug ( filename + " has been modified " )
logSys . debug ( " %s has been modified " , filename )
self . __ lastModTime[ filename ] = logStats . st_mtime
self . __ prevStats[ filename ] = stats
return True
return True
except OSError , e :
except OSError , e :
logSys . error ( " Unable to get stat on %s because of: %s "
logSys . error ( " Unable to get stat on %s because of: %s "