Rev 6510: (jameinel) Detect if we are not progressing during osutils.send_all() and in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/
Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Sep 11 07:57:07 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/
------------------------------------------------------------
revno: 6510 [merge]
revision-id: pqm at pqm.ubuntu.com-20120911075707-gyi8ss0rkgprg3h2
parent: pqm at pqm.ubuntu.com-20120907110410-fqh06iqg61pknazl
parent: john at arbash-meinel.com-20120911072651-0rys0d8a06xks71u
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.5
timestamp: Tue 2012-09-11 07:57:07 +0000
message:
(jameinel) Detect if we are not progressing during osutils.send_all() and
fail rather than hang. (bug #1047309) (John A Meinel)
modified:
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2012-02-28 04:58:14 +0000
+++ b/bzrlib/osutils.py 2012-09-11 07:26:51 +0000
@@ -2140,8 +2140,12 @@
if e.args[0] != errno.EINTR:
raise
else:
+ if sent == 0:
+ raise errors.ConnectionReset('Sending to %s returned 0 bytes'
+ % (sock,))
sent_total += sent
- report_activity(sent, 'write')
+ if report_activity is not None:
+ report_activity(sent, 'write')
def connect_socket(address):
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2012-02-28 04:58:14 +0000
+++ b/bzrlib/tests/test_osutils.py 2012-09-11 07:26:51 +0000
@@ -819,6 +819,28 @@
self.assertEqual(None, osutils.safe_file_id(None))
+
+class TestSendAll(tests.TestCase):
+
+ 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 TestPosixFuncs(tests.TestCase):
"""Test that the posix version of normpath returns an appropriate path
when used with 2 leading slashes."""
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2012-09-06 12:05:27 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2012-09-07 13:15:02 +0000
@@ -39,6 +39,13 @@
extracted texts from the repository. (Just an ordering constraint on how
they consumed the stream.) (John Arbash Meinel, #1046284)
+* ``osutils.send_all`` now detects if we get a series of zero bytes sent,
+ and fails with a ECONNRESET. It seems if paramiko gets disconnected, it
+ will get into a state where it returns 0 bytes sent, but doesn't raise
+ an error. This change allows us to get a couple hiccups of no content
+ sent, but if it is consistent, we will consider it to be a failure.
+ (John Arbash Meinel, #1047309)
+
* Revert use of --no-tty when gpg signing commits. (Jelmer Vernooij, #1014570)
* Some small bug fixes wrt lightweight checkouts and remote repositories.
More information about the bazaar-commits
mailing list