|
|
|
@ -327,15 +327,18 @@ class Actions(JailThread, Mapping):
|
|
|
|
|
self._jail.name, name, e,
|
|
|
|
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
|
|
|
|
while self.active:
|
|
|
|
|
try:
|
|
|
|
|
if self.idle:
|
|
|
|
|
logSys.debug("Actions: enter idle mode")
|
|
|
|
|
Utils.wait_for(lambda: not self.active or not self.idle,
|
|
|
|
|
lambda: False, self.sleeptime)
|
|
|
|
|
logSys.debug("Actions: leave idle mode")
|
|
|
|
|
continue
|
|
|
|
|
# wait for ban (stop if gets inactive):
|
|
|
|
|
# wait for ban (stop if gets inactive, pending ban or unban):
|
|
|
|
|
bancnt = 0
|
|
|
|
|
if Utils.wait_for(lambda: not self.active or self._jail.hasFailTickets, self.sleeptime):
|
|
|
|
|
wt = min(self.sleeptime, self.__banManager._nextUnbanTime - MyTime.time())
|
|
|
|
|
logSys.log(5, "Actions: wait for pending tickets %s (default %s)", wt, self.sleeptime)
|
|
|
|
|
if Utils.wait_for(lambda: not self.active or self._jail.hasFailTickets, wt):
|
|
|
|
|
bancnt = self.__checkBan()
|
|
|
|
|
cnt += bancnt
|
|
|
|
|
# unban if nothing is banned not later than banned tickets >= banPrecedence
|
|
|
|
@ -343,8 +346,13 @@ class Actions(JailThread, Mapping):
|
|
|
|
|
if self.active:
|
|
|
|
|
# let shrink the ban list faster
|
|
|
|
|
bancnt *= 2
|
|
|
|
|
logSys.log(5, "Actions: check-unban %s, bancnt %s, max: %s", bancnt if bancnt and bancnt < self.unbanMaxCount else self.unbanMaxCount, bancnt, self.unbanMaxCount)
|
|
|
|
|
self.__checkUnBan(bancnt if bancnt and bancnt < self.unbanMaxCount else self.unbanMaxCount)
|
|
|
|
|
cnt = 0
|
|
|
|
|
except Exception as e: # pragma: no cover
|
|
|
|
|
logSys.error("[%s] unhandled error in actions thread: %s",
|
|
|
|
|
self._jail.name, e,
|
|
|
|
|
exc_info=logSys.getEffectiveLevel()<=logging.DEBUG)
|
|
|
|
|
|
|
|
|
|
self.__flushBan(stop=True)
|
|
|
|
|
self.stopActions()
|
|
|
|
|