mirror of https://github.com/fail2ban/fail2ban
attempt to speedup ban- and fail-manager (e. g. fail2ban-client status, see gh-2819), remove unneeded lock (GIL is enough here)
parent
a038fd5dfe
commit
f555ff45e9
|
@ -66,8 +66,7 @@ class BanManager:
|
|||
# @param value the time
|
||||
|
||||
def setBanTime(self, value):
|
||||
with self.__lock:
|
||||
self.__banTime = int(value)
|
||||
self.__banTime = int(value)
|
||||
|
||||
##
|
||||
# Get the ban time.
|
||||
|
@ -76,8 +75,7 @@ class BanManager:
|
|||
# @return the time
|
||||
|
||||
def getBanTime(self):
|
||||
with self.__lock:
|
||||
return self.__banTime
|
||||
return self.__banTime
|
||||
|
||||
##
|
||||
# Set the total number of banned address.
|
||||
|
@ -85,8 +83,7 @@ class BanManager:
|
|||
# @param value total number
|
||||
|
||||
def setBanTotal(self, value):
|
||||
with self.__lock:
|
||||
self.__banTotal = value
|
||||
self.__banTotal = value
|
||||
|
||||
##
|
||||
# Get the total number of banned address.
|
||||
|
@ -94,8 +91,7 @@ class BanManager:
|
|||
# @return the total number
|
||||
|
||||
def getBanTotal(self):
|
||||
with self.__lock:
|
||||
return self.__banTotal
|
||||
return self.__banTotal
|
||||
|
||||
##
|
||||
# Returns a copy of the IP list.
|
||||
|
@ -103,8 +99,7 @@ class BanManager:
|
|||
# @return IP list
|
||||
|
||||
def getBanList(self):
|
||||
with self.__lock:
|
||||
return list(self.__banList.keys())
|
||||
return list(self.__banList.keys())
|
||||
|
||||
##
|
||||
# Returns a iterator to ban list (used in reload, so idle).
|
||||
|
@ -112,9 +107,8 @@ 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:
|
||||
return iter(list(self.__banList.values()))
|
||||
# ensure iterator is safe - traverse over the list in snapshot created within lock (GIL):
|
||||
return iter(list(self.__banList.values()))
|
||||
|
||||
##
|
||||
# Returns normalized value
|
||||
|
|
|
@ -47,12 +47,10 @@ class FailManager:
|
|||
self.__bgSvc = BgService()
|
||||
|
||||
def setFailTotal(self, value):
|
||||
with self.__lock:
|
||||
self.__failTotal = value
|
||||
self.__failTotal = value
|
||||
|
||||
def getFailTotal(self):
|
||||
with self.__lock:
|
||||
return self.__failTotal
|
||||
return self.__failTotal
|
||||
|
||||
def getFailCount(self):
|
||||
# may be slow on large list of failures, should be used for test purposes only...
|
||||
|
@ -123,8 +121,7 @@ class FailManager:
|
|||
return attempts
|
||||
|
||||
def size(self):
|
||||
with self.__lock:
|
||||
return len(self.__failList)
|
||||
return len(self.__failList)
|
||||
|
||||
def cleanup(self, time):
|
||||
with self.__lock:
|
||||
|
|
Loading…
Reference in New Issue