diff options
author | Peter Portante <peter.portante@redhat.com> | 2012-12-12 21:01:09 -0500 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-12-17 06:17:04 -0800 |
commit | cdcbc5bb3dfd2b447df0dff843d7774a1a463a09 (patch) | |
tree | 0f5a8c8331601c7279bd4e1072e706242e0f6040 | |
parent | a1f4a415374b4ff9afd847b7a1fbb4890c5e34a1 (diff) |
object-storage: only open file when requested
Only open a file when the caller of the constructor indicates that it
expects to have a file pointer to access in the "fp" field.
Found by Junaid during review http://review.gluster.org/4284, Patch
set 6.
We also bump the version number to mark a line in the set of changes
we want to perform a mini release with to double check for performance
regressions.
Change-Id: I13cf336bb519088890192ee111f4ece85a5982c4
BUG: 886730
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Reviewed-on: http://review.gluster.org/4303
Reviewed-by: Mohammed Junaid <junaid@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r-- | ufo/gluster-swift-ufo.spec | 2 | ||||
-rw-r--r-- | ufo/gluster/swift/common/DiskFile.py | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/ufo/gluster-swift-ufo.spec b/ufo/gluster-swift-ufo.spec index 8d2c93b8be3..8c0167cb73f 100644 --- a/ufo/gluster-swift-ufo.spec +++ b/ufo/gluster-swift-ufo.spec @@ -16,7 +16,7 @@ %define _confdir %{_sysconfdir}/swift %define _ufo_version 1.1 -%define _ufo_release 3 +%define _ufo_release 4 Summary : GlusterFS Unified File and Object Storage. Name : gluster-swift-ufo diff --git a/ufo/gluster/swift/common/DiskFile.py b/ufo/gluster/swift/common/DiskFile.py index 8522295483d..62f98103762 100644 --- a/ufo/gluster/swift/common/DiskFile.py +++ b/ufo/gluster/swift/common/DiskFile.py @@ -137,9 +137,13 @@ class Gluster_DiskFile(DiskFile): if os.path.isdir(data_file): self._is_dir = True else: - self.fp = do_open(data_file, 'rb') - if not keep_data_fp: - self.close(verify_file=False) + if keep_data_fp: + # The caller has an assumption that the "fp" field of this + # object is an file object if keep_data_fp is set. However, + # this implementation of the DiskFile object does not need to + # open the file for internal operations. So if the caller + # requests it, we'll just open the file for them. + self.fp = do_open(data_file, 'rb') def close(self, verify_file=True): """ |