Rev 3066: Allow pycurl users to watch the blinkenlights and fix a bug when ranges are contiguous. in file:///v/home/vila/src/bzr/bugs/173010/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Dec 3 17:53:39 GMT 2007
At file:///v/home/vila/src/bzr/bugs/173010/
------------------------------------------------------------
revno: 3066
revision-id:v.ladeuil+lp at free.fr-20071203175335-1u285fvj1ejbjlqb
parent: v.ladeuil+lp at free.fr-20071203163410-7o415a4mjn5ih2ni
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 173010
timestamp: Mon 2007-12-03 18:53:35 +0100
message:
Allow pycurl users to watch the blinkenlights and fix a bug when ranges are contiguous.
* bzrlib/transport/http/response.py:
(RangeFile.read): Fix indentation.
(RangeFile.seek): Off-by-one error if the pos is after the
range (i.e. at start + size), the range has been fully read, the
next range should be started.
* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport): Limit coalescing to issur more requests to
compensate for the pycurl lack of feedback.
* bzrlib/transport/http/__init__.py:
(HttpTransportBase._get_ranges_hinted): Catch InvalidHttpRange,
not InvalidRange which cannot occur here.
* bzrlib/tests/test_http_response.py:
(TestRangeFileAccess._file_multi_ranges): Add a third range
contiguous to the second one.
(TestRangeFileAccess.test_valid_accesses): Test the case where the
last read ends at the end of the range leaving pos at a value
equals to the start of a next contiguous range.
modified:
bzrlib/tests/test_http_response.py test_http_response.py-20060628233143-950b2a482a32505d
bzrlib/transport/http/__init__.py http_transport.py-20050711212304-506c5fd1059ace96
bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
bzrlib/transport/http/response.py _response.py-20060613154423-a2ci7hd4iw5c7fnt-1
-------------- next part --------------
=== modified file 'bzrlib/tests/test_http_response.py'
--- a/bzrlib/tests/test_http_response.py 2007-12-03 16:34:10 +0000
+++ b/bzrlib/tests/test_http_response.py 2007-12-03 17:53:35 +0000
@@ -63,7 +63,7 @@
content = []
content += bline
file_size = 200
- for (start, part) in [(10, alpha), (100, alpha)]:
+ for (start, part) in [(10, alpha), (100, alpha), (126, alpha.upper())]:
plen = len(part)
content += 'Content-Range: bytes %d-%d/%d\r\n' % (start,
start+plen-1,
@@ -110,7 +110,15 @@
# We crossed a range boundary, so now the file is positioned at the
# start of the new range (i.e. trying to seek below 100 will error out)
f.seek(100)
- f.seek(126)
+ f.seek(125)
+
+ f = self._file_multi_ranges()
+ self.assertEquals(self.alpha, f.read()) # Read first range
+ f.seek(100)
+ self.assertEquals(self.alpha, f.read()) # Read second range
+ self.assertEquals(126, f.tell())
+ f.seek(126) # Start of third range which is also the current pos !
+ self.assertEquals('A', f.read(1))
def _check_file_boundaries(self, f, start=0):
f.seek(start)
=== modified file 'bzrlib/transport/http/__init__.py'
--- a/bzrlib/transport/http/__init__.py 2007-12-03 16:34:10 +0000
+++ b/bzrlib/transport/http/__init__.py 2007-12-03 17:53:35 +0000
@@ -192,7 +192,7 @@
try_again = False
try:
code, f = self._get(relpath, ranges)
- except errors.InvalidRange, e:
+ except errors.InvalidHttpRange, e:
if exc_info is None:
exc_info = sys.exc_info()
self._degrade_range_hint(relpath, ranges, exc_info)
@@ -211,7 +211,8 @@
# specified.
_bytes_to_read_before_seek = 128
# No limit on the offset number that get combined into one, we are trying
- # to avoid downloading the whole file.
+ # to avoid downloading the whole file. But see _pycurl.py for a different
+ # use.
_max_readv_combine = 0
# By default Apache has a limit of ~400 ranges before replying with a 400
# Bad Request. So we go underneath that amount to be safe.
=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py 2007-12-03 09:14:07 +0000
+++ b/bzrlib/transport/http/_pycurl.py 2007-12-03 17:53:35 +0000
@@ -208,6 +208,14 @@
return code, data
+ # The mother class use 0 to minimize the requests, but since we can't
+ # exploit the results as soon as they are received (pycurl limitation) we'd
+ # better issue more requests and provide a more responsive UI do the cost
+ # of more latency costs.
+ # If you modify this think about modifying the comment in http/__init__.py
+ # too.
+ _max_readv_combine = 25
+
def _get_ranged(self, relpath, offsets, tail_amount):
"""Make a request for just part of the file."""
curl = self._get_curl()
=== modified file 'bzrlib/transport/http/response.py'
--- a/bzrlib/transport/http/response.py 2007-12-03 08:33:06 +0000
+++ b/bzrlib/transport/http/response.py 2007-12-03 17:53:35 +0000
@@ -161,10 +161,9 @@
request not entirely consumed by the client (due to offset coalescing)
"""
if self._pos < self._start:
- raise errors.InvalidRange(self._path, self._pos,
- "Can't read before range (%s, %s)"
- % (self._start, self._size))
-
+ raise errors.InvalidRange(self._path, self._pos,
+ "Can't read before range (%s, %s)"
+ % (self._start, self._size))
if self._size > 0:
if size > 0 and self._pos + size > self._start + self._size:
raise errors.InvalidRange(
@@ -208,7 +207,7 @@
if self._size > 0:
cur_limit = self._start + self._size
- while final_pos > cur_limit:
+ while final_pos >= cur_limit:
# We will cross range boundaries
remain = cur_limit - self._pos
if remain > 0:
More information about the bazaar-commits
mailing list