Fix certificate expiration scheduler

timedelta.seconds does not store the total seconds of a time span.
Internally, seconds is the next smaller unit to days, hence
timedelta.seconds will never exceed (or reach) the number of seconds
in a day (60*60*24=86400)
This commit is contained in:
Florian Fieber 2012-08-19 16:20:58 +02:00 committed by Lance Stout
parent 8a03bd72ae
commit e510875f64

View file

@ -901,9 +901,15 @@ class XMLStream(object):
log.warn('CERT: Certificate has expired.')
restart()
try:
total_seconds = cert_ttl.total_seconds()
except AttributeError:
# for Python < 2.7
total_seconds = (cert_ttl.microseconds + (cert_ttl.seconds + cert_ttl.days * 24 * 3600) * 10**6) / 10**6
log.info('CERT: Time until certificate expiration: %s' % cert_ttl)
self.schedule('Certificate Expiration',
cert_ttl.seconds,
total_seconds,
restart)
def _start_keepalive(self, event):