Created
March 1, 2014 02:47
-
-
Save clayg/9284301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py | |
index aecc752..79ce477 100644 | |
--- a/swift/proxy/controllers/obj.py | |
+++ b/swift/proxy/controllers/obj.py | |
@@ -658,6 +658,7 @@ class ObjectController(Controller): | |
return HTTPServiceUnavailable(request=req) | |
bytes_transferred = 0 | |
try: | |
+ req_failed = False | |
with ContextPool(len(nodes)) as pool: | |
for conn in conns: | |
conn.failed = False | |
@@ -674,6 +675,7 @@ class ObjectController(Controller): | |
break | |
bytes_transferred += len(chunk) | |
if bytes_transferred > MAX_FILE_SIZE: | |
+ req_failed = True | |
return HTTPRequestEntityTooLarge(request=req) | |
for conn in list(conns): | |
if not conn.failed: | |
@@ -687,6 +689,7 @@ class ObjectController(Controller): | |
'Object PUT exceptions during' | |
' send, %(conns)s/%(nodes)s required connections'), | |
{'conns': len(conns), 'nodes': min_conns}) | |
+ req_failed = True | |
return HTTPServiceUnavailable(request=req) | |
for conn in conns: | |
if conn.queue.unfinished_tasks: | |
@@ -696,11 +699,17 @@ class ObjectController(Controller): | |
self.app.logger.warn( | |
_('ERROR Client read timeout (%ss)'), err.seconds) | |
self.app.logger.increment('client_timeouts') | |
+ req_failed = True | |
return HTTPRequestTimeout(request=req) | |
except (Exception, Timeout): | |
self.app.logger.exception( | |
_('ERROR Exception causing client disconnect')) | |
+ req_failed = True | |
return HTTPClientDisconnect(request=req) | |
+ finally: | |
+ if req_failed: | |
+ for conn in conns: | |
+ conn.close() | |
if req.content_length and bytes_transferred < req.content_length: | |
req.client_disconnect = True | |
self.app.logger.warn( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment