mirror of https://github.com/fail2ban/fail2ban
now polling backend only: prevent completely read of big files first time (after start of service), initial seek to start time using half-interval search algorithm (see issue #795):
disabled for gamin and pyinotify backends;pull/716/head
parent
930678cc0e
commit
c1637e97b2
|
@ -76,7 +76,7 @@ class FilterGamin(FileFilter):
|
|||
TODO -- RF:
|
||||
this is a common logic and must be shared/provided by FileFilter
|
||||
"""
|
||||
self.getFailures(path, MyTime.time() - self.getFindTime())
|
||||
self.getFailures(path)
|
||||
try:
|
||||
while True:
|
||||
ticket = self.failManager.toBan()
|
||||
|
|
|
@ -55,6 +55,7 @@ class FilterPoll(FileFilter):
|
|||
## The time of the last modification of the file.
|
||||
self.__prevStats = dict()
|
||||
self.__file404Cnt = dict()
|
||||
self.__initial = dict()
|
||||
logSys.debug("Created FilterPoll")
|
||||
|
||||
##
|
||||
|
@ -83,7 +84,6 @@ class FilterPoll(FileFilter):
|
|||
# @return True when the thread exits nicely
|
||||
|
||||
def run(self):
|
||||
cntr = 0
|
||||
while self.active:
|
||||
if logSys.getEffectiveLevel() <= 6:
|
||||
logSys.log(6, "Woke up idle=%s with %d files monitored",
|
||||
|
@ -93,8 +93,11 @@ class FilterPoll(FileFilter):
|
|||
for container in self.getLogPath():
|
||||
filename = container.getFileName()
|
||||
if self.isModified(filename):
|
||||
self.getFailures(filename, (MyTime.time() - self.getFindTime()) if not cntr else None)
|
||||
cntr += 1
|
||||
# set start time as now - find time for first usage only (prevent performance bug with polling of big files)
|
||||
self.getFailures(filename,
|
||||
(MyTime.time() - self.getFindTime()) if not self.__initial.get(filename) else None
|
||||
)
|
||||
self.__initial[filename] = True
|
||||
self.__modified = True
|
||||
|
||||
if self.__modified:
|
||||
|
|
|
@ -102,7 +102,7 @@ class FilterPyinotify(FileFilter):
|
|||
TODO -- RF:
|
||||
this is a common logic and must be shared/provided by FileFilter
|
||||
"""
|
||||
self.getFailures(path, MyTime.time() - self.getFindTime())
|
||||
self.getFailures(path)
|
||||
try:
|
||||
while True:
|
||||
ticket = self.failManager.toBan()
|
||||
|
|
Loading…
Reference in New Issue