Rev 3464: Fix HPSS protocol version detection so that it doesn't unnecessarily in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jun 2 00:36:32 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3464
revision-id:pqm at pqm.ubuntu.com-20080601233619-di6or8d3o26n917q
parent: pqm at pqm.ubuntu.com-20080530221339-0l4zj40k4dknzaqw
parent: andrew.bennetts at canonical.com-20080601230822-mzdjbbwol57spk5x
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2008-06-02 00:36:19 +0100
message:
Fix HPSS protocol version detection so that it doesn't unnecessarily
disconnect when the server correctly responds with an error code.
modified:
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/message.py message.py-20080222013625-ncqmh3nrxjkxab87-1
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
------------------------------------------------------------
revno: 3461.2.2
revision-id:andrew.bennetts at canonical.com-20080601230822-mzdjbbwol57spk5x
parent: andrew.bennetts at canonical.com-20080530043339-gvr9z2o13cldsos6
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: smart-protocol-detection-fix
timestamp: Mon 2008-06-02 09:08:22 +1000
message:
Tweak suggested by John.
modified:
bzrlib/smart/message.py message.py-20080222013625-ncqmh3nrxjkxab87-1
------------------------------------------------------------
revno: 3461.2.1
revision-id:andrew.bennetts at canonical.com-20080530043339-gvr9z2o13cldsos6
parent: pqm at pqm.ubuntu.com-20080530010236-e3x7ckdc25s57pgc
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: smart-protocol-detection-fix
timestamp: Fri 2008-05-30 14:33:39 +1000
message:
Avoid unnecessary reconnections to old servers when the first HPSS is an error in the right protocol version.
modified:
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/message.py message.py-20080222013625-ncqmh3nrxjkxab87-1
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py 2008-05-20 00:42:19 +0000
+++ b/bzrlib/smart/client.py 2008-05-30 04:33:39 +0000
@@ -76,6 +76,11 @@
% (protocol_version,))
self._medium.disconnect()
continue
+ except errors.ErrorFromSmartServer:
+ # If we received an error reply from the server, then it
+ # must be ok with this protocol version.
+ self._medium._protocol_version = protocol_version
+ raise
else:
self._medium._protocol_version = protocol_version
return response_tuple, response_handler
=== modified file 'bzrlib/smart/message.py'
--- a/bzrlib/smart/message.py 2008-05-14 07:35:27 +0000
+++ b/bzrlib/smart/message.py 2008-06-01 23:08:22 +0000
@@ -237,6 +237,11 @@
bytes = self._medium_request.read_bytes(next_read_size)
if bytes == '':
# end of file encountered reading from server
+ if 'hpss' in debug.debug_flags:
+ mutter(
+ 'decoder state: buf[:10]=%r, state_accept=%s',
+ self._protocol_decoder._in_buffer[:10],
+ self._protocol_decoder.state_accept.__name__)
raise errors.ConnectionReset(
"please check connectivity and permissions",
"(and try -Dhpss if further diagnosis is required)")
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py 2008-05-23 07:02:37 +0000
+++ b/bzrlib/tests/test_smart_transport.py 2008-05-30 04:33:39 +0000
@@ -2590,6 +2590,7 @@
def __init__(self):
self.calls = []
+ self._medium = 'dummy medium'
def accept_bytes(self, bytes):
self.calls.append('accept_bytes')
@@ -2924,7 +2925,40 @@
errors.SmartProtocolError,
smart_client.call, 'method-name', 'arg 1', 'arg 2')
self.assertEqual([], medium._expected_events)
+
+ def test_first_response_is_error(self):
+ """If the server replies with an error, then the version detection
+ should be complete.
+ This test is very similar to test_version_two_server, but catches a bug
+ we had in the case where the first reply was an error response.
+ """
+ medium = MockMedium()
+ smart_client = client._SmartClient(medium, headers={})
+ message_start = protocol.MESSAGE_VERSION_THREE + '\x00\x00\x00\x02de'
+ # Issue a request that gets an error reply in a non-default protocol
+ # version.
+ medium.expect_request(
+ message_start +
+ 's\x00\x00\x00\x10l11:method-nameee',
+ 'bzr response 2\nfailed\n\n')
+ medium.expect_disconnect()
+ medium.expect_request(
+ 'bzr request 2\nmethod-name\n',
+ 'bzr response 2\nfailed\nFooBarError\n')
+ err = self.assertRaises(
+ errors.ErrorFromSmartServer,
+ smart_client.call, 'method-name')
+ self.assertEqual(('FooBarError',), err.error_tuple)
+ # Now the medium should have remembered the protocol version, so
+ # subsequent requests will use the remembered version immediately.
+ medium.expect_request(
+ 'bzr request 2\nmethod-name\n',
+ 'bzr response 2\nsuccess\nresponse value\n')
+ result = smart_client.call('method-name')
+ self.assertEqual(('response value',), result)
+ self.assertEqual([], medium._expected_events)
+
class Test_SmartClient(tests.TestCase):
More information about the bazaar-commits
mailing list