code review: switch MAX_TIME to 0X7FFFFFFFFFFF (is enough, because 4461763-th year, but better performance)

pull/1557/head
sebres 2016-09-23 09:32:10 +02:00
parent e00be5f308
commit 004879b5b1
2 changed files with 5 additions and 3 deletions

View File

@ -57,7 +57,7 @@ class BanManager:
## Total number of banned IP address ## Total number of banned IP address
self.__banTotal = 0 self.__banTotal = 0
## The time for next unban process (for performance and load reasons): ## The time for next unban process (for performance and load reasons):
self.__nextUnbanTime = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL self.__nextUnbanTime = BanTicket.MAX_TIME
## ##
# Set the ban time. # Set the ban time.
@ -322,7 +322,7 @@ class BanManager:
# Gets the list of ticket to remove (thereby correct next unban time). # Gets the list of ticket to remove (thereby correct next unban time).
unBanList = {} unBanList = {}
self.__nextUnbanTime = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL self.__nextUnbanTime = BanTicket.MAX_TIME
for fid,ticket in self.__banList.iteritems(): for fid,ticket in self.__banList.iteritems():
# current time greater as end of ban - timed out: # current time greater as end of ban - timed out:
eob = ticket.getEndOfBanTime(self.__banTime) eob = ticket.getEndOfBanTime(self.__banTime)

View File

@ -35,6 +35,8 @@ logSys = getLogger(__name__)
class Ticket(object): class Ticket(object):
MAX_TIME = 0X7FFFFFFFFFFF ;# 4461763-th year
RESTORED = 0x01 RESTORED = 0x01
BANNED = 0x08 BANNED = 0x08
@ -112,7 +114,7 @@ class Ticket(object):
bantime = (self._banTime if self._banTime is not None else defaultBT) bantime = (self._banTime if self._banTime is not None else defaultBT)
# permanent # permanent
if bantime == -1: if bantime == -1:
return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL return Ticket.MAX_TIME
# unban time (end of ban): # unban time (end of ban):
return self._time + bantime return self._time + bantime