Commit 792523a7 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

added bug fix to solve race condition (ticket:248)

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 5371
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 71fc3bbc
......@@ -47,6 +47,10 @@
# 14/03/2013 V0.6.2 make use with statement
# 26/10/2013 V0.6.3 increase verbosity in debug mode (CsFile.update())
# 08/11/2013 V0.6.4 Time processing bugs fixed.
# 05/12/2013 V0.6.5 (thof) bug fix ticket:248 (race condition when excluding
# files based on time stamp values) for open time windows
# (like all younger than 3 days), we use datetime.max as
# the end time
#
# =============================================================================
""" CsFile module to handle checksumfiles. """
......@@ -64,7 +68,7 @@ from datetime import date
import csbacklog
import csbackErrorCodes as eCodes
__version__ = "V0.6.2"
__version__ = "V0.6.5"
__subversion__ = "$Id$"
__license__ = "GPLv2+"
__author__ = "Daniel Armbruster"
......@@ -517,10 +521,22 @@ class CsTimeProcessor:
"""
Generate datetimes tuples for file exclusion.
The generated tuples contain two elements (index 0 and 1):
index 0: beginning of time window (start)
index 1: end of time window (end)
The time window does not contain the start and end time themselves (this is
the way time windows are evaluated in CsFile.update()
Minute processing is done within this class though time processing was passed
to remote abstract TimeProcessor class.
"""
def __init__(self, min, time, daystart=False):
"""
Parameters:
min: arguments to -[acm]min parameter
time: arguments to [-acm]time parameter
daystart: daystart flag (value is true, if option is selected)
"""
self.result = []
self.min = min
self.time = time
......@@ -577,12 +593,12 @@ class CsTimeProcessor:
if 0 != minPlus:
self.result.append((datetime.min,start-timedelta(minutes=minPlus)))
if 0 != minMinus:
self.result.append((start+timedelta(minutes=minMinus), start))
self.result.append((start+timedelta(minutes=minMinus), datetime.max))
elif abs(minPlus) == abs(minMinus):
pass
else:
if 0 == minPlus:
self.result.append((start+timedelta(minutes=minMinus), start))
self.result.append((start+timedelta(minutes=minMinus), datetime.max))
else:
self.result.append((start+timedelta(minutes=minMinus), \
start-timedelta(minutes=minPlus+1)))
......@@ -642,12 +658,12 @@ class StandardTimeProcessor(TimeProcessor):
if 0 != timePlus:
self.result.append((datetime.min, start-timedelta(days=timePlus+1)))
if 0 != timeMinus:
self.result.append((start+timedelta(days=timeMinus), start))
self.result.append((start+timedelta(days=timeMinus), datetime.max))
elif abs(timePlus) == abs(timeMinus):
pass
else:
if 0 == timePlus:
self.result.append((start+timedelta(days=timeMinus), start))
self.result.append((start+timedelta(days=timeMinus), datetime.max))
else:
self.result.append((start+timedelta(days=timeMinus), \
start-timedelta(days=timePlus+1)))
......@@ -682,7 +698,7 @@ class DaystartTimeProcessor(TimeProcessor):
# process daystart times
if len(timePlus) and len(timeMinus):
# case 1:
# ============|---------------------|==============|--------->
# ============|---------------------|==============|=========>
# ^ ^ ^ t
# exclude | include | exclude |
# daystart-timePlus daystart+timeMinus now
......@@ -690,7 +706,7 @@ class DaystartTimeProcessor(TimeProcessor):
self.result.append((datetime.min, \
start-timedelta(days=timePlus[-1])))
self.result.append((start+timedelta(days=timeMinus[-1]), \
datetime.now()))
datetime.max))
# case 2: same times -> do nothing
elif abs(timePlus[-1]) == abs(timeMinus[-1]):
pass
......@@ -711,21 +727,21 @@ class DaystartTimeProcessor(TimeProcessor):
self.result.append((datetime.min, start-timedelta(days=timePlus[-1])))
# case 5:
# ------------|============|---------->
# ------------|============|==========>
# ^ ^ t
# include | exclude | include
# daystart+timeMinus+1 now
elif 0 == len(timePlus) and len(timeMinus):
self.result.append((start+timedelta(days=timeMinus[-1]+1), \
datetime.now()))
datetime.max))
for t in timeFixed:
if 0 == t:
# case 6:
# ----------------|===========|------------->
# ----------------|===========|=============>
# ^ ^ t
# | exclude |
# daystart now
self.result.append((start, datetime.now()))
self.result.append((start, datetime.max))
else:
# case 7:
# ----------------|==================|---------|--------->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment