mirror of https://github.com/fail2ban/fail2ban
sleep a little bit in error case (to get around time-related errors, e.g. something like log-rotate, etc.)
parent
6454d0cd75
commit
1d6b546658
|
@ -29,6 +29,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from .failmanager import FailManagerEmpty, FailManager
|
from .failmanager import FailManagerEmpty, FailManager
|
||||||
from .ipdns import DNSUtils, IPAddr
|
from .ipdns import DNSUtils, IPAddr
|
||||||
|
@ -443,8 +444,10 @@ class Filter(JailThread):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logSys.error("Failed to process line: %r, caught exception: %r", line, e,
|
logSys.error("Failed to process line: %r, caught exception: %r", line, e,
|
||||||
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
||||||
# incr error counter, stop processing this :
|
# incr error counter, stop processing (going idle) after 100th error :
|
||||||
self.__errors += 1
|
self.__errors += 1
|
||||||
|
# sleep a little bit (to get around time-related errors):
|
||||||
|
time.sleep(self.sleeptime)
|
||||||
if self.__errors >= 100:
|
if self.__errors >= 100:
|
||||||
logSys.error("Too many errors at once (%s), going idle", self.__errors)
|
logSys.error("Too many errors at once (%s), going idle", self.__errors)
|
||||||
self.__errors //= 2
|
self.__errors //= 2
|
||||||
|
|
|
@ -605,6 +605,7 @@ class LogFileMonitor(LogCaptureTestCase):
|
||||||
self.assertLogged('Unable to open %s' % self.name)
|
self.assertLogged('Unable to open %s' % self.name)
|
||||||
|
|
||||||
def testErrorProcessLine(self):
|
def testErrorProcessLine(self):
|
||||||
|
self.filter.sleeptime /= 1000.0
|
||||||
## produce error with not callable processLine:
|
## produce error with not callable processLine:
|
||||||
_org_processLine = self.filter.processLine
|
_org_processLine = self.filter.processLine
|
||||||
self.filter.processLine = None
|
self.filter.processLine = None
|
||||||
|
|
Loading…
Reference in New Issue