Rev 4913: Finish backporting the osutils.send_all changes. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-reconnect-819604
John Arbash Meinel
john at arbash-meinel.com
Tue Sep 11 12:27:01 UTC 2012
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-client-reconnect-819604
------------------------------------------------------------
revno: 4913
revision-id: john at arbash-meinel.com-20120911122646-j2x1rxlbgnrkyoox
parent: john at arbash-meinel.com-20120911074559-p0pre5od6hkpu082
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-client-reconnect-819604
timestamp: Tue 2012-09-11 16:26:46 +0400
message:
Finish backporting the osutils.send_all changes.
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2012-09-11 07:45:59 +0000
+++ b/bzrlib/osutils.py 2012-09-11 12:26:46 +0000
@@ -1988,8 +1988,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 dereference_path(path):
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2012-09-11 07:45:59 +0000
+++ b/bzrlib/tests/test_osutils.py 2012-09-11 12:26:46 +0000
@@ -821,6 +821,24 @@
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."""
More information about the bazaar-commits
mailing list