/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-25 12:40:39 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061025124039-ee626546953e0f95
Fix a race condition that make selftest fail once in a while.

* HTTPTestUtil.py:
(WallRequestHandler.handle_one_request): Be more strict to close
the connection to avoid a race condition with a client able to
read before we really close.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    def handle_one_request(self):
37
37
        """Handle a single HTTP request, by abruptly closing the connection"""
38
38
        self.close_connection = 1
 
39
        # But informing higher levels that we *will* close, is
 
40
        # not enough. There is a race condition when the client
 
41
        # is able to try to read before the server can really
 
42
        # close the socket. In that case the client will raise a
 
43
        # InvalidHttpResponse instead of a ConnectionError. And
 
44
        # we want to make it raise ConnectionError, so let's be a
 
45
        # bit more brutal.
 
46
        self.wfile.close()
39
47
 
40
48
 
41
49
class BadStatusRequestHandler(TestingHTTPRequestHandler):