mirror of https://github.com/fail2ban/fail2ban
fixed sporadically (multi-threading) errors by reload/stop/start of polling filter inside getModified (so prevents to stop running main cycle)
parent
c1174d7935
commit
10bdadaef2
|
@ -97,6 +97,7 @@ class FilterPoll(FileFilter):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.active:
|
while self.active:
|
||||||
|
try:
|
||||||
if logSys.getEffectiveLevel() <= 6:
|
if logSys.getEffectiveLevel() <= 6:
|
||||||
logSys.log(6, "Woke up idle=%s with %d files monitored",
|
logSys.log(6, "Woke up idle=%s with %d files monitored",
|
||||||
self.idle, self.getLogCount())
|
self.idle, self.getLogCount())
|
||||||
|
@ -123,6 +124,13 @@ class FilterPoll(FileFilter):
|
||||||
except FailManagerEmpty:
|
except FailManagerEmpty:
|
||||||
self.failManager.cleanup(MyTime.time())
|
self.failManager.cleanup(MyTime.time())
|
||||||
self.__modified = False
|
self.__modified = False
|
||||||
|
except Exception as e: # pragma: no cover
|
||||||
|
if not self.active: # if not active - error by stop...
|
||||||
|
break
|
||||||
|
logSys.error("Caught unhandled exception in main cycle: %r", e,
|
||||||
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
||||||
|
# incr common error counter:
|
||||||
|
self.commonError()
|
||||||
logSys.debug("[%s] filter terminated", self.jailName)
|
logSys.debug("[%s] filter terminated", self.jailName)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -151,9 +159,9 @@ class FilterPoll(FileFilter):
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# stil alive (may be deleted because multi-threaded):
|
# stil alive (may be deleted because multi-threaded):
|
||||||
if not self.getLog(filename):
|
if not self.getLog(filename) or self.__prevStats.get(filename) is None:
|
||||||
logSys.warning("Log %r seems to be down: %s", filename, e)
|
logSys.warning("Log %r seems to be down: %s", filename, e)
|
||||||
return
|
return False
|
||||||
# log error:
|
# log error:
|
||||||
if self.__file404Cnt[filename] < 2:
|
if self.__file404Cnt[filename] < 2:
|
||||||
logSys.error("Unable to get stat on %s because of: %s",
|
logSys.error("Unable to get stat on %s because of: %s",
|
||||||
|
|
Loading…
Reference in New Issue