Rev 3707: Fix bug #246233: TooManyConcurrentRequests errors at the start of in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Sep 12 14:52:57 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3707
revision-id: pqm at pqm.ubuntu.com-20080912135247-pyukwwmlmz79d61r
parent: pqm at pqm.ubuntu.com-20080912082648-k8wi6vkcjghx1km0
parent: andrew.bennetts at canonical.com-20080912080218-hl6l0h3mf54tgik3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-09-12 14:52:47 +0100
message:
  Fix bug #246233: TooManyConcurrentRequests errors at the start of
  	pull/merge. (Andrew Bennetts)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/bundle/__init__.py      changeset.py-20050513021216-b02ab57fb9738913
  bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
    ------------------------------------------------------------
    revno: 3703.2.3
    revision-id: andrew.bennetts at canonical.com-20080912080218-hl6l0h3mf54tgik3
    parent: andrew.bennetts at canonical.com-20080912042034-kv3t9zxvsz9y0n4c
    parent: pqm at pqm.ubuntu.com-20080912075746-kg3w6klh2bufrjd6
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-pull-bug-246233
    timestamp: Fri 2008-09-12 18:02:18 +1000
    message:
      Merge from bzr.dev.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/smart/message.py        message.py-20080222013625-ncqmh3nrxjkxab87-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
      bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/tree_implementations/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
      bzrlib/tests/workingtree_implementations/test_rename_one.py test_rename_one.py-20070226161242-2d8ibdedl700jgio-1
      bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
    ------------------------------------------------------------
    revno: 3703.2.2
    revision-id: andrew.bennetts at canonical.com-20080912042034-kv3t9zxvsz9y0n4c
    parent: andrew.bennetts at canonical.com-20080912021352-qwm26ehnsxm7bvk7
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-pull-bug-246233
    timestamp: Fri 2008-09-12 14:20:34 +1000
    message:
      Add NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3703.2.1
    revision-id: andrew.bennetts at canonical.com-20080912021352-qwm26ehnsxm7bvk7
    parent: pqm at pqm.ubuntu.com-20080911061059-svzqfejar17ui4zw
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: smart-pull-bug-246233
    timestamp: Fri 2008-09-12 12:13:52 +1000
    message:
      Allow ConnectionReset to propagate from read_mergeable_from_url.
    modified:
      bzrlib/bundle/__init__.py      changeset.py-20050513021216-b02ab57fb9738913
      bzrlib/tests/test_bundle.py    test.py-20050630184834-092aa401ab9f039c
=== modified file 'NEWS'
--- a/NEWS	2008-09-12 07:57:46 +0000
+++ b/NEWS	2008-09-12 08:02:18 +0000
@@ -18,6 +18,10 @@
     * Fix '_in_buffer' AttributeError when using the -Dhpss debug flag.
       (Andrew Bennetts)
 
+    * Fix TooManyConcurrentRequests errors caused by a connection failure
+      when doing ``bzr pull`` or ``bzr merge`` from a ``bzr+ssh`` URL.
+      (Andrew Bennetts, #246233)
+
   DOCUMENTATION:
 
   API CHANGES:

=== modified file 'bzrlib/bundle/__init__.py'
--- a/bzrlib/bundle/__init__.py	2008-03-25 01:25:28 +0000
+++ b/bzrlib/bundle/__init__.py	2008-09-12 02:13:52 +0000
@@ -82,6 +82,8 @@
             return directive, transport
         else:
             return _serializer.read_bundle(f), transport
+    except errors.ConnectionReset:
+        raise
     except (errors.TransportError, errors.PathError), e:
         raise errors.NotABundle(str(e))
     except (IOError,), e:

=== modified file 'bzrlib/tests/test_bundle.py'
--- a/bzrlib/tests/test_bundle.py	2008-09-11 10:53:31 +0000
+++ b/bzrlib/tests/test_bundle.py	2008-09-12 08:02:18 +0000
@@ -16,7 +16,9 @@
 
 from cStringIO import StringIO
 import os
+import socket
 import sys
+import threading
 
 from bzrlib import (
     bzrdir,
@@ -1587,3 +1589,49 @@
         self.build_tree_contents([('./foo:bar', out.getvalue())])
         self.assertRaises(errors.NotABundle, read_mergeable_from_url,
                           'foo:bar')
+
+    def test_smart_server_connection_reset(self):
+        """If a smart server connection fails during the attempt to read a
+        bundle, then the ConnectionReset error should be propagated.
+        """
+        # Instantiate a server that will provoke a ConnectionReset
+        sock_server = _DisconnectingTCPServer()
+        sock_server.setUp()
+        self.addCleanup(sock_server.tearDown)
+        url = sock_server.get_url()
+        self.assertRaises(errors.ConnectionReset, read_mergeable_from_url, url)
+
+
+class _DisconnectingTCPServer(object):
+    """A TCP server that immediately closes any connection made to it."""
+
+    def setUp(self):
+        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.sock.bind(('127.0.0.1', 0))
+        self.sock.listen(1)
+        self.port = self.sock.getsockname()[1]
+        self.thread = threading.Thread(
+            name='%s (port %d)' % (self.__class__.__name__, self.port),
+            target=self.accept_and_close)
+        self.thread.start()
+
+    def accept_and_close(self):
+        conn, addr = self.sock.accept()
+        conn.shutdown(socket.SHUT_RDWR)
+        conn.close()
+
+    def get_url(self):
+        return 'bzr://127.0.0.1:%d/' % (self.port,)
+
+    def tearDown(self):
+        try:
+            # make sure the thread dies by connecting to the listening socket,
+            # just in case the test failed to do so.
+            conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            conn.connect(self.sock.getsockname())
+            conn.close()
+        except socket.error:
+            pass
+        self.sock.close()
+        self.thread.join()
+




More information about the bazaar-commits mailing list