Rev 4523: (andrew) Fix bug in HPSS v3 decoder when receiving multiple lots of in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Jul 9 02:44:03 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4523 [merge]
revision-id: pqm at pqm.ubuntu.com-20090709014400-y2e7prh8mejs2j26
parent: pqm at pqm.ubuntu.com-20090709004425-6tukiuklys5y02m5
parent: andrew.bennetts at canonical.com-20090709002524-s8qlere6h0blex9a
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-07-09 02:44:00 +0100
message:
  (andrew) Fix bug in HPSS v3 decoder when receiving multiple lots of
  	excess bytes.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
  bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
=== modified file 'NEWS'
--- a/NEWS	2009-07-09 00:44:25 +0000
+++ b/NEWS	2009-07-09 01:44:00 +0000
@@ -78,6 +78,10 @@
   of a remote repository.
   (Jelmer Vernooij, #332194)
 
+* Fix bug in decoding v3 smart server messages when receiving multiple
+  lots of excess bytes after an end-of-message.
+  (Andrew Bennetts)
+
 * Force deletion of readonly files during merge, update and other tree
   transforms.
   (Craig Hewetson, Martin Pool, #218206)

=== modified file 'bzrlib/smart/protocol.py'
--- a/bzrlib/smart/protocol.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/smart/protocol.py	2009-07-08 07:03:38 +0000
@@ -1036,7 +1036,7 @@
             raise errors.SmartMessageHandlerError(sys.exc_info())
 
     def _state_accept_reading_unused(self):
-        self.unused_data = self._get_in_buffer()
+        self.unused_data += self._get_in_buffer()
         self._set_in_buffer(None)
 
     def next_read_size(self):

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2009-07-07 04:31:47 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2009-07-08 07:03:38 +0000
@@ -2297,6 +2297,23 @@
         self.assertEqual(0, smart_protocol.next_read_size())
         self.assertEqual('', smart_protocol.unused_data)
 
+    def test_repeated_excess(self):
+        """Repeated calls to accept_bytes after the message end has been parsed
+        accumlates the bytes in the unused_data attribute.
+        """
+        output = StringIO()
+        headers = '\0\0\0\x02de'  # length-prefixed, bencoded empty dict
+        end = 'e'
+        request_bytes = headers + end
+        smart_protocol = self.server_protocol_class(LoggingMessageHandler())
+        smart_protocol.accept_bytes(request_bytes)
+        self.assertEqual('', smart_protocol.unused_data)
+        smart_protocol.accept_bytes('aaa')
+        self.assertEqual('aaa', smart_protocol.unused_data)
+        smart_protocol.accept_bytes('bbb')
+        self.assertEqual('aaabbb', smart_protocol.unused_data)
+        self.assertEqual(0, smart_protocol.next_read_size())
+
     def make_protocol_expecting_message_part(self):
         headers = '\0\0\0\x02de'  # length-prefixed, bencoded empty dict
         message_handler = LoggingMessageHandler()




More information about the bazaar-commits mailing list