Rev 2795: Readv fixes. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Mon Oct 8 05:54:01 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2795
revision-id: robertc at robertcollins.net-20071008045350-qwh1gb3r9vy3c8kk
parent: robertc at robertcollins.net-20071008020231-cmw2wkbm9t9c1yxq
parent: robertc at robertcollins.net-20071008044749-07yl1rtr3v9iw62o
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Mon 2007-10-08 14:53:50 +1000
message:
  Readv fixes.
modified:
  bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
  bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
    ------------------------------------------------------------
    revno: 2592.1.25.2.7.1.28.1.6.1.3.1.9.2.1.3.74.1.31.3.18.1.9.1.2.1.12.1.8.1.46.1.18.1.1.1.2
    revision-id: robertc at robertcollins.net-20071008044749-07yl1rtr3v9iw62o
    parent: robertc at robertcollins.net-20071006072506-fypnagvqddbyh4q9
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: readv
    timestamp: Mon 2007-10-08 14:47:49 +1000
    message:
      More readv adjust for latency tests and bugfixes.
    modified:
      bzrlib/tests/test_transport_implementations.py test_transport_implementations.py-20051227111451-f97c5c7d5c49fce7
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
=== modified file 'bzrlib/tests/test_transport_implementations.py'
--- a/bzrlib/tests/test_transport_implementations.py	2007-10-04 22:00:07 +0000
+++ b/bzrlib/tests/test_transport_implementations.py	2007-10-08 04:53:50 +0000
@@ -1551,7 +1551,22 @@
             self.assertTrue(result[0][0] <= 400)
             self.assertTrue(result[0][0] + data_len >= 1034)
             check_result_data(result)
-        
+        # test from observed failure case.
+        if transport.is_readonly():
+            file('a', 'w').write('a'*1024*1024)
+        else:
+            transport.put_bytes('a', 'a'*1024*1024)
+        broken_vector = [(465219, 800), (225221, 800), (445548, 800),
+            (225037, 800), (221357, 800), (437077, 800), (947670, 800),
+            (465373, 800), (947422, 800)]
+        results = list(transport.readv('a', broken_vector, True, 1024*1024))
+        found_items = [False]*9
+        for pos, (start, length) in enumerate(broken_vector):
+            # check the range is covered by the result
+            for offset, data in results:
+                if offset <= start and start + length <= offset + len(data):
+                    found_items[pos] = True
+        self.assertEqual([True]*9, found_items)
 
     def test_get_with_open_write_stream_sees_all_content(self):
         t = self.get_transport()

=== modified file 'bzrlib/transport/__init__.py'
--- a/bzrlib/transport/__init__.py	2007-10-08 02:02:31 +0000
+++ b/bzrlib/transport/__init__.py	2007-10-08 04:53:50 +0000
@@ -695,14 +695,20 @@
             current_offset, current_length = new_offsets[0]
             current_finish = current_length + current_offset
             for offset, length in new_offsets[1:]:
+                finish = offset + length
                 if offset > current_finish:
+                    # there is a gap, output the current accumulator and start
+                    # a new one for the region we're examining.
                     offsets.append((current_offset, current_length))
                     current_offset = offset
                     current_length = length
+                    current_finish = finish
                     continue
-                finish = offset + length
                 if finish > current_finish:
+                    # extend the current accumulator to the end of the region
+                    # we're examining.
                     current_finish = finish
+                    current_length = finish - current_offset
             offsets.append((current_offset, current_length))
         return self._readv(relpath, offsets)
 



More information about the bazaar-commits mailing list