Rev 6512: Merge up 2.4-client-reconnect-819604 and resolve the inevitable conflicts. in http://bazaar.launchpad.net/~jameinel/2.5/2.5-merge-up-2.4
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 14 08:03:13 UTC 2012
At http://bazaar.launchpad.net/~jameinel/2.5/2.5-merge-up-2.4
------------------------------------------------------------
revno: 6512 [merge]
revision-id: john at arbash-meinel.com-20120914080235-3ag35vp442w3158u
parent: pqm at pqm.ubuntu.com-20120911090908-1xx05ree9c58y4in
parent: john at arbash-meinel.com-20120914074133-vcv93rb32ywydvaw
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-merge-up-2.4
timestamp: Fri 2012-09-14 12:02:35 +0400
message:
Merge up 2.4-client-reconnect-819604 and resolve the inevitable conflicts.
modified:
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2012-09-11 08:39:14 +0000
+++ b/bzrlib/osutils.py 2012-09-14 08:02:35 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2011 Canonical Ltd
+# Copyright (C) 2005-2012 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
# and need the former on windows
import shutil
from shutil import rmtree
+import signal
import socket
import subprocess
# We need to import both tempfile and mkdtemp as we export the later on posix
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2012-09-10 11:50:34 +0000
+++ b/bzrlib/smart/medium.py 2012-09-14 08:02:35 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011 Canonical Ltd
+# Copyright (C) 2006-2012 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1093,6 +1093,20 @@
SmartClientSocketMedium.__init__(self, base)
self._host = host
self._port = port
+ self._socket = None
+
+ def _accept_bytes(self, bytes):
+ """See SmartClientMedium.accept_bytes."""
+ self._ensure_connection()
+ osutils.send_all(self._socket, bytes, self._report_activity)
+
+ def disconnect(self):
+ """See SmartClientMedium.disconnect()."""
+ if not self._connected:
+ return
+ self._socket.close()
+ self._socket = None
+ self._connected = False
def _ensure_connection(self):
"""Connect this medium if not already connected."""
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2012-01-06 22:06:36 +0000
+++ b/bzrlib/smart/request.py 2012-09-14 08:02:35 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006-2011 Canonical Ltd
+# Copyright (C) 2006-2012 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2012-09-11 08:39:14 +0000
+++ b/bzrlib/tests/test_osutils.py 2012-09-14 08:02:35 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2011 Canonical Ltd
+# Copyright (C) 2005-2012 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -868,6 +868,45 @@
self.assertEqual('/etc/shadow', osutils._posix_normpath('///etc/shadow'))
+class TestSendAll(tests.TestCase):
+
+ def test_send_with_disconnected_socket(self):
+ class DisconnectedSocket(object):
+ def __init__(self, err):
+ self.err = err
+ def send(self, content):
+ raise self.err
+ def close(self):
+ pass
+ # All of these should be treated as ConnectionReset
+ errs = []
+ for err_cls in (IOError, socket.error):
+ for errnum in osutils._end_of_stream_errors:
+ errs.append(err_cls(errnum))
+ for err in errs:
+ sock = DisconnectedSocket(err)
+ self.assertRaises(errors.ConnectionReset,
+ osutils.send_all, sock, 'some more content')
+
+ def test_send_with_no_progress(self):
+ # See https://bugs.launchpad.net/bzr/+bug/1047309
+ # It seems that paramiko can get into a state where it doesn't error,
+ # but it returns 0 bytes sent for requests over and over again.
+ class NoSendingSocket(object):
+ def __init__(self):
+ self.call_count = 0
+ def send(self, bytes):
+ self.call_count += 1
+ if self.call_count > 100:
+ # Prevent the test suite from hanging
+ raise RuntimeError('too many calls')
+ return 0
+ sock = NoSendingSocket()
+ self.assertRaises(errors.ConnectionReset,
+ osutils.send_all, sock, 'content')
+ self.assertEqual(1, sock.call_count)
+
+
class TestWin32Funcs(tests.TestCase):
"""Test that _win32 versions of os utilities return appropriate paths."""
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt 2012-06-18 10:46:42 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt 2012-09-14 08:02:35 +0000
@@ -41,6 +41,11 @@
* Fix "Unprintable exception" error when a RetryWithNewPacks error is
displayed. (Andrew Bennetts)
+* Teach the bzr client how to reconnect if we get ``ConnectionReset``
+ while making an RPC request. This doesn't handle all possible network
+ disconnects, but it should at least handle when the server is asked to
+ shutdown gracefully. (John Arbash Meinel, #819604)
+
Documentation
*************
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2012-09-05 18:16:08 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2012-09-14 08:02:35 +0000
@@ -118,8 +118,8 @@
Bug Fixes
*********
-* Fixed an infinite loop when creating a repo at the root of the filesystem,
- i.e. "/", due to posixpath.normpath() not collapsing 2 leading slashes into
+* Fixed an infinite loop when creating a repo at the root of the filesystem,
+ i.e. "/", due to posixpath.normpath() not collapsing 2 leading slashes into
one, thus respecting the POSIX standard, but making relpath() loop infinitely.
(Florian Vichot, #861008)
@@ -137,6 +137,12 @@
avoids raising a spurious MemoryError on certain platforms such as AIX.
(John Arbash Meinel, #856731)
+* Teach the bzr client how to reconnect if we get ``ConnectionReset``
+ while making an RPC request. This doesn't handle all possible network
+ disconnects, but it should at least handle when the server is asked to
+ shutdown gracefully. (John Arbash Meinel, #819604)
+
+
Documentation
*************
More information about the bazaar-commits
mailing list