Merge "Make ssync_receiver drop conn on exc"

This commit is contained in:
Jenkins 2013-12-19 20:06:32 +00:00 committed by Gerrit Code Review
commit 9a2275cfd2
2 changed files with 9 additions and 9 deletions

View File

@ -65,7 +65,10 @@ class Receiver(object):
self.device = None
self.partition = None
self.fp = None
self.disconnect = False
# We default to dropping the connection in case there is any exception
# raised during processing because otherwise the sender could send for
# quite some time before realizing it was all in vain.
self.disconnect = True
def __call__(self):
"""
@ -100,6 +103,9 @@ class Receiver(object):
yield data
for data in self.updates():
yield data
# We didn't raise an exception, so end the request
# normally.
self.disconnect = False
finally:
if self.app.replication_semaphore:
self.app.replication_semaphore.release()
@ -288,10 +294,6 @@ class Receiver(object):
raise Exception('Looking for :UPDATES: START got %r' % line[:1024])
successes = 0
failures = 0
# We default to dropping the connection in case there is any exception
# raised during processing because otherwise the sender could send for
# quite some time before realizing it was all in vain.
self.disconnect = True
while True:
with exceptions.MessageTimeout(
self.app.client_timeout, 'updates line'):
@ -376,8 +378,6 @@ class Receiver(object):
raise swob.HTTPInternalServerError(
'ERROR: With :UPDATES: %d failures to %d successes' %
(failures, successes))
# We didn't raise an exception, so end the request normally.
self.disconnect = False
yield ':UPDATES: START\r\n'
yield ':UPDATES: END\r\n'
for data in self._ensure_flush():

View File

@ -365,7 +365,7 @@ class TestReceiver(unittest.TestCase):
self.body_lines(resp.body),
[":ERROR: 408 '0.01 seconds: missing_check line'"])
self.assertEqual(resp.status_int, 200)
self.assertFalse(mock_shutdown_safe.called)
self.assertTrue(mock_shutdown_safe.called)
self.controller.logger.error.assert_called_once_with(
'2.3.4.5/sda1/1 TIMEOUT in replication.Receiver: '
'0.01 seconds: missing_check line')
@ -407,7 +407,7 @@ class TestReceiver(unittest.TestCase):
self.body_lines(resp.body),
[":ERROR: 0 'test exception'"])
self.assertEqual(resp.status_int, 200)
self.assertFalse(mock_shutdown_safe.called)
self.assertTrue(mock_shutdown_safe.called)
self.controller.logger.exception.assert_called_once_with(
'3.4.5.6/sda1/1 EXCEPTION in replication.Receiver')