Merge lp:~vila/bzr/306264-pycurl-recv-error into lp:~bzr/bzr/trunk-old

Proposed by Vincent Ladeuil
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vila/bzr/306264-pycurl-recv-error
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 115 lines (has conflicts)
Text conflict in NEWS
To merge this branch: bzr merge lp:~vila/bzr/306264-pycurl-recv-error
Reviewer Review Type Date Requested Status
Andrew Bennetts Pending
Review via email: mp+10402@code.launchpad.net

This proposal supersedes a proposal from 2009-08-19.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote : Posted in a previous version of this proposal

I was finally able to reproduce the (reported long ago) problem with newer pycurl.

The priority was low because that occured only in torture tests. Yet, it was causing failures on karmic recently.

Hopefully we'll have a clean selftest run now, which makes me quite warmer inside
with 2.0 across the corner :-)

Revision history for this message
Vincent Ladeuil (vila) wrote : Posted in a previous version of this proposal

There are more cases than are closely related and need additional fixing.

review: Needs Resubmitting
Revision history for this message
Vincent Ladeuil (vila) wrote :

So this new fix is more complete as it turns out that the error should be turned into
a ConnectionReset instead.

And doing so, some minor tweaks are needed but more importantly it also address a rarely seen
problem in the urllib implementation.

Revision history for this message
Robert Collins (lifeless) wrote :

review +1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-08-19 18:04:49 +0000
3+++ NEWS 2009-08-20 02:35:11 +0000
4@@ -9,6 +9,29 @@
5 In Development
6 ##############
7
8+<<<<<<< TREE
9+=======
10+Bug Fixes
11+*********
12+
13+* Fix a pycurl related test failure on karmic by recognizing an error
14+ raised by newer versions of pycurl.
15+ (Vincent Ladeuil, #306264)
16+
17+* Fix a test failure on karmic by making a locale test more robust.
18+ (Vincent Ladeuil, #413514)
19+
20+Improvements
21+************
22+
23+* A better description of the platform is shown in crash tracebacks, ``bzr
24+ --version`` and ``bzr selftest``.
25+ (Martin Pool, #409137)
26+
27+bzr 1.18
28+########
29+
30+>>>>>>> MERGE-SOURCE
31 Compatibility Breaks
32 ********************
33
34
35=== modified file 'bzrlib/tests/test_http.py'
36--- bzrlib/tests/test_http.py 2009-06-10 03:56:49 +0000
37+++ bzrlib/tests/test_http.py 2009-08-20 02:35:12 +0000
38@@ -625,14 +625,17 @@
39 # for details) make no distinction between a closed
40 # socket and badly formatted status line, so we can't
41 # just test for ConnectionError, we have to test
42- # InvalidHttpResponse too.
43- self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
44+ # InvalidHttpResponse too. And pycurl may raise ConnectionReset
45+ # instead of ConnectionError too.
46+ self.assertRaises(( errors.ConnectionError, errors.ConnectionReset,
47+ errors.InvalidHttpResponse),
48 t.has, 'foo/bar')
49
50 def test_http_get(self):
51 server = self.get_readonly_server()
52 t = self._transport(server.get_url())
53- self.assertRaises((errors.ConnectionError, errors.InvalidHttpResponse),
54+ self.assertRaises((errors.ConnectionError, errors.ConnectionReset,
55+ errors.InvalidHttpResponse),
56 t.get, 'foo/bar')
57
58
59
60=== modified file 'bzrlib/transport/http/__init__.py'
61--- bzrlib/transport/http/__init__.py 2009-04-27 03:27:46 +0000
62+++ bzrlib/transport/http/__init__.py 2009-08-20 02:35:12 +0000
63@@ -617,7 +617,7 @@
64 raise InvalidHttpResponse(
65 t._remote_path('.bzr/smart'),
66 'Expected 200 response code, got %r' % (code,))
67- except errors.InvalidHttpResponse, e:
68+ except (errors.InvalidHttpResponse, errors.ConnectionReset), e:
69 raise errors.SmartProtocolError(str(e))
70 return body_filelike
71
72
73=== modified file 'bzrlib/transport/http/_pycurl.py'
74--- bzrlib/transport/http/_pycurl.py 2009-03-23 14:59:43 +0000
75+++ bzrlib/transport/http/_pycurl.py 2009-08-20 02:35:12 +0000
76@@ -92,6 +92,7 @@
77 CURLE_GOT_NOTHING = _get_pycurl_errcode('E_GOT_NOTHING', 52)
78 CURLE_PARTIAL_FILE = _get_pycurl_errcode('E_PARTIAL_FILE', 18)
79 CURLE_SEND_ERROR = _get_pycurl_errcode('E_SEND_ERROR', 55)
80+CURLE_RECV_ERROR = _get_pycurl_errcode('E_RECV_ERROR', 56)
81 CURLE_SSL_CACERT = _get_pycurl_errcode('E_SSL_CACERT', 60)
82 CURLE_SSL_CACERT_BADFILE = _get_pycurl_errcode('E_SSL_CACERT_BADFILE', 77)
83
84@@ -367,6 +368,9 @@
85 ):
86 raise errors.ConnectionError(
87 'curl connection error (%s)\non %s' % (e[1], url))
88+ elif e[0] == CURLE_RECV_ERROR:
89+ raise errors.ConnectionReset(
90+ 'curl connection error (%s)\non %s' % (e[1], url))
91 elif e[0] == CURLE_PARTIAL_FILE:
92 # Pycurl itself has detected a short read. We do not have all
93 # the information for the ShortReadvError, but that should be
94
95=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
96--- bzrlib/transport/http/_urllib2_wrappers.py 2009-05-04 15:21:26 +0000
97+++ bzrlib/transport/http/_urllib2_wrappers.py 2009-08-20 02:35:12 +0000
98@@ -46,6 +46,7 @@
99 # actual code more or less do that, tests should be written to
100 # ensure that.
101
102+import errno
103 import httplib
104 try:
105 import kerberos
106@@ -541,6 +542,10 @@
107 request.get_full_url(),
108 'Bad status line received',
109 orig_error=exc_val)
110+ elif (isinstance(exc_val, socket.error) and len(exc_val.args)
111+ and exc_val.args[0] in (errno.ECONNRESET, 10054)):
112+ raise errors.ConnectionReset(
113+ "Connection lost while sending request.")
114 else:
115 # All other exception are considered connection related.
116