diff options
author | Alistair Coles <alistairncoles@gmail.com> | 2020-12-29 15:09:24 +0000 |
---|---|---|
committer | Alistair Coles <alistairncoles@gmail.com> | 2020-12-29 16:14:28 +0000 |
commit | 5e3302649584b2aec523e5966671e43ea959ed27 (patch) | |
tree | 0427554e0242b40d280d78fd55b7eda06a462743 /swift/common/request_helpers.py | |
parent | 0d06bd5be8d97456d96e0ea9bbb99508ec85a2b5 (diff) | |
download | swift-5e3302649584b2aec523e5966671e43ea959ed27.tar.gz |
Use CloseableChain when creating iterator of SLO response
When handling a GET response ProxyLoggingMiddleware will try to close
a reiterated [1] proxy response iterator if, for example, there is a
client disconnect.
The reiterate function encapsulates the result of calling iter() on
the proxy response. In the case of an SLO response, the iter method
returned an instance of iterchools.chain, rather than the response
itself, which is an instance of SegmentedIterable. As a result the
SegmentedIterable.close() method would not be called and object server
connections would not be closed.
This patch replaces the iterchools.chain with a CloseableChain which
encapsulates the SegmentedIterable and closes it when
CloseableChain.close() is called.
[1] The use of reiterate was introduced by the Related-Change.
Closes-Bug: #1909588
Related-Change: I27feabe923a6520e983637a9c68a19ec7174a0df
Change-Id: Ib7450a85692114973782525004466db49f63066d
Diffstat (limited to 'swift/common/request_helpers.py')
-rw-r--r-- | swift/common/request_helpers.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/swift/common/request_helpers.py b/swift/common/request_helpers.py index 8b3940fe5..e01d1a004 100644 --- a/swift/common/request_helpers.py +++ b/swift/common/request_helpers.py @@ -39,7 +39,7 @@ from swift.common.utils import split_path, validate_device_partition, \ close_if_possible, maybe_multipart_byteranges_to_document_iters, \ multipart_byteranges_to_document_iters, parse_content_type, \ parse_content_range, csv_append, list_from_csv, Spliterator, quote, \ - RESERVED, config_true_value, md5 + RESERVED, config_true_value, md5, CloseableChain from swift.common.wsgi import make_subrequest @@ -736,7 +736,7 @@ class SegmentedIterable(object): if self.peeked_chunk is not None: pc = self.peeked_chunk self.peeked_chunk = None - return itertools.chain([pc], self.app_iter) + return CloseableChain([pc], self.app_iter) else: return self.app_iter |