attempt to speedup ban- and fail-manager (e. g. fail2ban-client status, see gh-2819), remove unneeded lock (GIL is enough here)

pull/2842/head^2^2
sebres 2020-09-07 19:08:52 +02:00
parent a038fd5dfe
commit f555ff45e9
2 changed files with 10 additions and 19 deletions

View File

@ -66,7 +66,6 @@ class BanManager:
# @param value the time
def setBanTime(self, value):
with self.__lock:
self.__banTime = int(value)
##
@ -76,7 +75,6 @@ class BanManager:
# @return the time
def getBanTime(self):
with self.__lock:
return self.__banTime
##
@ -85,7 +83,6 @@ class BanManager:
# @param value total number
def setBanTotal(self, value):
with self.__lock:
self.__banTotal = value
##
@ -94,7 +91,6 @@ class BanManager:
# @return the total number
def getBanTotal(self):
with self.__lock:
return self.__banTotal
##
@ -103,7 +99,6 @@ class BanManager:
# @return IP list
def getBanList(self):
with self.__lock:
return list(self.__banList.keys())
##
@ -112,8 +107,7 @@ class BanManager:
# @return ban list iterator
def __iter__(self):
# ensure iterator is safe (traverse over the list in snapshot created within lock):
with self.__lock:
# ensure iterator is safe - traverse over the list in snapshot created within lock (GIL):
return iter(list(self.__banList.values()))
##

View File

@ -47,11 +47,9 @@ class FailManager:
self.__bgSvc = BgService()
def setFailTotal(self, value):
with self.__lock:
self.__failTotal = value
def getFailTotal(self):
with self.__lock:
return self.__failTotal
def getFailCount(self):
@ -123,7 +121,6 @@ class FailManager:
return attempts
def size(self):
with self.__lock:
return len(self.__failList)
def cleanup(self, time):