aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test.txt
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-06-14 15:37:19 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-18 12:05:29 +0100
commit7d098d89e509af9cbd3748bbae0fd3e1cf4df771 (patch)
tree91bf6aba2cfdf8e0921dab0f81bec9e871cd9118 /tests/test.txt
parentc0961f69d6311160c27e12e7294954e88c5af05b (diff)
downloadsos-7d098d89e509af9cbd3748bbae0fd3e1cf4df771.tar.gz
[archive] make FileCacheArchive methods re-entrant
Since plugins are now run concurrently the Archive class must be re-entrant: different plugins may attempt to create the same paths in the archive, and since they are executing in parallel and with no locking, there exists a TOCTOU race between the use of os.path.{exists,isdir, etc.}() and the subsequent creation of a new path. Address this by implementing a simple monitor-style locking scheme for the FileCacheArchive class. A `_path_lock` member is added to the class and this must be held across any operation that modifies the namespace of the archive (including file, directory, symlink, and special node creation). Additionally, the `_check_path()` Archive method (which checks for the existence of path components up to the basename of the file, creating directories as required) is extended to also carry out a test for the existence of the path, and if the path does exist, that the object is of the expected type. A mismatch in the object type generates a ValueError with an appropriate string description of the problem. Benchmarking shows a consistent small improvement with the patch: this is a result of reduced redundant copy operations that the previous archive structure allowed (since duplicate operations are now aborted as soon as the _path_lock is acquired). Resolves: #1340 Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
Diffstat (limited to 'tests/test.txt')
0 files changed, 0 insertions, 0 deletions