From a5c1444faa827dc2e3d85468d42622acea1d435e Mon Sep 17 00:00:00 2001 From: Romain de Joux Date: Tue, 19 Jul 2022 15:22:31 +0200 Subject: [PATCH] Drain and close response in StaticLargeObject.get_slo_segments In get_slo_segments a GET subrequest is processed to get SLO manifest, but if the object is not a SLO the response was not drain/closed. Closes-Bug: 1980954 Change-Id: I7862c8ef153416c00c8ca7d6bf2f3556a1776d8c --- swift/common/middleware/slo.py | 2 ++ test/unit/common/middleware/test_slo.py | 1 + 2 files changed, 3 insertions(+) diff --git a/swift/common/middleware/slo.py b/swift/common/middleware/slo.py index 857a52f224..49783587fc 100644 --- a/swift/common/middleware/slo.py +++ b/swift/common/middleware/slo.py @@ -1532,6 +1532,8 @@ class StaticLargeObject(object): except ValueError: raise HTTPServerError('Unable to load SLO manifest') else: + # Drain and close GET request (prevents socket leaks) + drain_and_close(resp) raise HTTPBadRequest('Not an SLO manifest') elif resp.status_int == HTTP_NOT_FOUND: raise HTTPNotFound('SLO manifest not found') diff --git a/test/unit/common/middleware/test_slo.py b/test/unit/common/middleware/test_slo.py index b7b1365e84..c723f9ff66 100644 --- a/test/unit/common/middleware/test_slo.py +++ b/test/unit/common/middleware/test_slo.py @@ -1490,6 +1490,7 @@ class TestSloDeleteManifest(SloTestCase): self.assertEqual(resp_data['Number Not Found'], 0) self.assertEqual(resp_data['Errors'], [['/deltest/a_1', 'Not an SLO manifest']]) + self.assertFalse(self.app.unread_requests) def test_handle_multipart_delete_bad_json(self): req = Request.blank(