Merge "Shutdown backend EC connection contexts on disconnect"

This commit is contained in:
Jenkins 2016-04-06 17:28:42 +00:00 committed by Gerrit Code Review
commit 475e448366
3 changed files with 26 additions and 16 deletions

View File

@ -926,6 +926,7 @@ class ResumingGetter(object):
if nchunks % 5 == 0: if nchunks % 5 == 0:
sleep() sleep()
part_iter = None
try: try:
while True: while True:
start_byte, end_byte, length, headers, part = \ start_byte, end_byte, length, headers, part = \
@ -939,6 +940,9 @@ class ResumingGetter(object):
self.pop_range() self.pop_range()
except StopIteration: except StopIteration:
req.environ['swift.non_client_disconnect'] = True req.environ['swift.non_client_disconnect'] = True
finally:
if part_iter:
part_iter.close()
except ChunkReadTimeout: except ChunkReadTimeout:
self.app.exception_occurred(node[0], _('Object'), self.app.exception_occurred(node[0], _('Object'),

View File

@ -1118,6 +1118,11 @@ class ECAppIter(object):
self.stashed_iter = None self.stashed_iter = None
def close(self): def close(self):
# close down the stashed iter first so the ContextPool can
# cleanup the frag queue feeding coros that may be currently
# executing the internal_parts_iters.
if self.stashed_iter:
self.stashed_iter.close()
for it in self.internal_parts_iters: for it in self.internal_parts_iters:
close_if_possible(it) close_if_possible(it)

View File

@ -5827,23 +5827,24 @@ class TestObjectController(unittest.TestCase):
exp = 'HTTP/1.1 201' exp = 'HTTP/1.1 201'
self.assertEqual(headers[:len(exp)], exp) self.assertEqual(headers[:len(exp)], exp)
# get object with mock.patch.object(_test_servers[0], 'client_timeout', new=5):
fd.write('GET /v1/a/ec-discon/test HTTP/1.1\r\n' # get object
'Host: localhost\r\n' fd.write('GET /v1/a/ec-discon/test HTTP/1.1\r\n'
'Connection: close\r\n' 'Host: localhost\r\n'
'X-Storage-Token: t\r\n' 'Connection: close\r\n'
'\r\n') 'X-Storage-Token: t\r\n'
fd.flush() '\r\n')
headers = readuntil2crlfs(fd) fd.flush()
exp = 'HTTP/1.1 200' headers = readuntil2crlfs(fd)
self.assertEqual(headers[:len(exp)], exp) exp = 'HTTP/1.1 200'
self.assertEqual(headers[:len(exp)], exp)
# read most of the object, and disconnect # read most of the object, and disconnect
fd.read(10) fd.read(10)
sock.fd._sock.close() sock.fd._sock.close()
condition = \ condition = \
lambda: _test_servers[0].logger.get_lines_for_level('warning') lambda: _test_servers[0].logger.get_lines_for_level('warning')
self._sleep_enough(condition) self._sleep_enough(condition)
# check for disconnect message! # check for disconnect message!
expected = ['Client disconnected on read'] * 2 expected = ['Client disconnected on read'] * 2