Browse Source

Fix a socket leak in case of broken connection

Change-Id: I39cbbe5915ab95fb0927b0899b8f09870b4c0b07
tags/1.5.0^0
Romain LE DISEZ 2 years ago
parent
commit
fc21cde1c2
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      ceilometermiddleware/swift.py

+ 8
- 0
ceilometermiddleware/swift.py View File

@@ -131,6 +131,11 @@ class InputProxy(object):
131 131
         self.bytes_received += len(line)
132 132
         return line
133 133
 
134
+    def close(self):
135
+        close_method = getattr(self.wsgi_input, 'close', None)
136
+        if callable(close_method):
137
+            close_method()
138
+
134 139
 
135 140
 class KeystoneClientLoader(ksa_adapter.Adapter):
136 141
     """Keystone client adapter loader.
@@ -272,6 +277,9 @@ class Swift(object):
272 277
                     except StopIteration:
273 278
                         chunk = ''
274 279
             finally:
280
+                close_method = getattr(iterable, 'close', None)
281
+                if callable(close_method):
282
+                    close_method()
275 283
                 self.emit_event(env, input_proxy.bytes_received, bytes_sent)
276 284
 
277 285
         try:

Loading…
Cancel
Save