Rev 2892: More readv adjust for latency tests and bugfixes. in http://people.ubuntu.com/~robertc/baz2.0/readv
Robert Collins
robertc at robertcollins.net
Mon Oct 8 05:47:57 BST 2007
At http://people.ubuntu.com/~robertc/baz2.0/readv
------------------------------------------------------------
revno: 2892
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 05:09:58 +0000
+++ b/bzrlib/tests/test_transport_implementations.py 2007-10-08 04:47:49 +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-06 07:25:06 +0000
+++ b/bzrlib/transport/__init__.py 2007-10-08 04:47:49 +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