Rev 4419: (andrew) Fix traceback in 'bzr serve' on Windows when a TCP client in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Jun 9 07:26:45 BST 2009


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

------------------------------------------------------------
revno: 4419
revision-id: pqm at pqm.ubuntu.com-20090609062641-6hs0exctaa1sz12m
parent: pqm at pqm.ubuntu.com-20090609042402-bmecxutc27lsgu91
parent: andrew.bennetts at canonical.com-20090609030359-nz021xhxn3p5ays3
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-06-09 07:26:41 +0100
message:
  (andrew) Fix traceback in 'bzr serve' on Windows when a TCP client
  	disconnects.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
    ------------------------------------------------------------
    revno: 4382.4.4
    revision-id: andrew.bennetts at canonical.com-20090609030359-nz021xhxn3p5ays3
    parent: andrew.bennetts at canonical.com-20090609030229-0mvfqp24gv9uc0z1
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: win-serve-error
    timestamp: Tue 2009-06-09 13:03:59 +1000
    message:
      Add NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 4382.4.3
    revision-id: andrew.bennetts at canonical.com-20090609030229-0mvfqp24gv9uc0z1
    parent: andrew.bennetts at canonical.com-20090609025701-8uzrcwelruo1uoj2
    parent: pqm at pqm.ubuntu.com-20090606005240-2qms4n1eqdshzp0w
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: win-serve-error
    timestamp: Tue 2009-06-09 13:02:29 +1000
    message:
      Merge bzr.dev.
    removed:
      bzrlib/util/tests/test_bencode.py test_bencode.py-20070713042202-qjw8rppxaz7ky6i6-1
    added:
      bzrlib/_bencode_pyx.h          _bencode_pyx.h-20090604155331-53bg7d0udmrvz44n-1
      bzrlib/_bencode_pyx.pyx        bencode.pyx-20070806220735-j75g4ebfnado2i60-3
      bzrlib/benchmarks/bench_tags.py bench_tags.py-20070812104202-0q5i0mqkt72hubof-1
      bzrlib/bencode.py              bencode.py-20070806220735-j75g4ebfnado2i60-2
      bzrlib/send.py                 send.py-20090521192735-j7cdb33ykmtmzx4w-1
      bzrlib/tests/per_repository_reference/test_fetch.py test_fetch.py-20090511214909-25pkgmoam913lrji-1
      bzrlib/tests/per_repository_reference/test_initialize.py test_initialize.py-20090527083941-4rz2urcthjet5e2i-1
      bzrlib/tests/per_repository_reference/test_unlock.py test_unlock.py-20090526160031-14lvypj5pbrndnyz-1
      bzrlib/tests/test_bencode.py   test_bencode.py-20070806225234-s51cnnkh6raytxti-1
      bzrlib/tests/test_chk_serializer.py test_chk_serializer.-20090515105921-urte9wnhknlj5dyp-1
    renamed:
      bzrlib/tests/workingtree_implementations/test_get_file_with_stat.py => bzrlib/tests/tree_implementations/test_get_file_with_stat.py test_get_file_with_s-20080922035909-lhdovrr36jpxmu0v-1
      bzrlib/util/bencode.py => bzrlib/util/_bencode_py.py bencode.py-20070220044742-sltr28q21w2wzlxi-1
    modified:
      .bzrignore                     bzrignore-20050311232317-81f7b71efa2db11a
      Makefile                       Makefile-20050805140406-d96e3498bb61c5bb
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/_groupcompress_pyx.pyx  _groupcompress_c.pyx-20080724041824-yelg6ii7c7zxt4z0-1
      bzrlib/benchmarks/__init__.py  __init__.py-20060516064526-eb0d37c78e86065d
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/bundle/serializer/v4.py v10.py-20070611062757-5ggj7k18s9dej0fr-1
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/cache_utf8.py           cache_utf8.py-20060810004311-x4cph46la06h9azm-1
      bzrlib/chk_serializer.py       chk_serializer.py-20081002064345-2tofdfj2eqq01h4b-1
      bzrlib/diff.py                 diff.py-20050309040759-26944fbbf2ebbf36
      bzrlib/foreign.py              foreign.py-20081112170002-olsxmandkk8qyfuq-1
      bzrlib/groupcompress.py        groupcompress.py-20080705181503-ccbxd6xuy1bdnrpu-8
      bzrlib/inventory.py            inventory.py-20050309040759-6648b84ca2005b37
      bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
      bzrlib/multiparent.py          __init__.py-20070410133617-n1jdhcc1n1mibarp-1
      bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
      bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
      bzrlib/plugins/launchpad/test_register.py test_register.py-20060315182712-40f5dda945c829a8
      bzrlib/python-compat.h         pythoncompat.h-20080924041409-9kvi0fgtuuqp743j-1
      bzrlib/reconcile.py            reweave_inventory.py-20051108164726-1e5e0934febac06e
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/groupcompress_repo.py repofmt.py-20080715094215-wp1qfvoo7093c8qr-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/serializer.py           serializer.py-20090402143702-wmkh9cfjhwpju0qi-1
      bzrlib/shelf.py                prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/smart/repository.py     repository.py-20061128022038-vr5wy5bubyb8xttk-1
      bzrlib/tag.py                  tag.py-20070212110532-91cw79inah2cfozx-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_add.py test_add.py-20060518072250-857e4f86f54a30b2
      bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
      bzrlib/tests/blackbox/test_export.py test_export.py-20051229024010-e6c26658e460fb1c
      bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
      bzrlib/tests/branch_implementations/test_check.py test_check.py-20080429151303-1sbfclxhddpz0tnj-1
      bzrlib/tests/branch_implementations/test_reconcile.py test_reconcile.py-20080429161555-qlmccuyeyt6pvho7-1
      bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
      bzrlib/tests/inventory_implementations/basics.py basics.py-20070903044446-kdjwbiu1p1zi9phs-1
      bzrlib/tests/per_repository/test_fetch.py test_fetch.py-20070814052151-5cxha9slx4c93uog-1
      bzrlib/tests/per_repository/test_fileid_involved.py test_file_involved.py-20051215205901-728a172d1014daaa
      bzrlib/tests/per_repository/test_iter_reverse_revision_history.py test_iter_reverse_re-20070217015036-spu7j5ggch7pbpyd-1
      bzrlib/tests/per_repository/test_reconcile.py test_reconcile.py-20060223022332-572ef70a3288e369
      bzrlib/tests/per_repository/test_revision.py testrevprops.py-20051013073044-92bc3c68302ce1bf
      bzrlib/tests/per_repository/test_write_group.py test_write_group.py-20070716105516-89n34xtogq5frn0m-1
      bzrlib/tests/per_repository_reference/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
      bzrlib/tests/per_repository_reference/test_default_stacking.py test_default_stackin-20090311055345-9ajahgm58oq3wh6h-1
      bzrlib/tests/test__groupcompress.py test__groupcompress_-20080724145854-koifwb7749cfzrvj-1
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
      bzrlib/tests/test_foreign.py   test_foreign.py-20081125004048-ywb901edgp9lluxo-1
      bzrlib/tests/test_graph.py     test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
      bzrlib/tests/test_groupcompress.py test_groupcompress.p-20080705181503-ccbxd6xuy1bdnrpu-13
      bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
      bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/tests/test_serializer.py test_serializer.py-20090403213933-q6x117y8t9fbeyoz-1
      bzrlib/tests/test_smart.py     test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
      bzrlib/tests/test_source.py    test_source.py-20051207061333-a58dea6abecc030d
      bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
      bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
      bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
      bzrlib/tests/workingtree_implementations/__init__.py __init__.py-20060203003124-b2aa5aca21a8bfad
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/transport/sftp.py       sftp.py-20051019050329-ab48ce71b7e32dfe
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
      bzrlib/versionedfile.py        versionedfile.py-20060222045106-5039c71ee3b65490
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
      bzrlib/tests/tree_implementations/test_get_file_with_stat.py test_get_file_with_s-20080922035909-lhdovrr36jpxmu0v-1
      bzrlib/util/_bencode_py.py     bencode.py-20070220044742-sltr28q21w2wzlxi-1
    ------------------------------------------------------------
    revno: 4382.4.2
    revision-id: andrew.bennetts at canonical.com-20090609025701-8uzrcwelruo1uoj2
    parent: andrew.bennetts at canonical.com-20090527142303-yfi2jxrmwqrlbw7g
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: win-serve-error
    timestamp: Tue 2009-06-09 12:57:01 +1000
    message:
      Refactor duplicated SmartServerSocketStreamMedium._read_bytes and SmartTCPClientMedium._read_bytes to share a common implementation with the best parts of both.  Includes Robert's review feedback.
    modified:
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
    ------------------------------------------------------------
    revno: 4382.4.1
    revision-id: andrew.bennetts at canonical.com-20090527142303-yfi2jxrmwqrlbw7g
    parent: pqm at pqm.ubuntu.com-20090526151333-3qckrxykl1x7op09
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: win-serve-error
    timestamp: Wed 2009-05-27 16:23:03 +0200
    message:
      Quick hack to suppress tracebacks in 'bzr serve' due to disconnecting clients.
    modified:
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
=== modified file 'NEWS'
--- a/NEWS	2009-06-09 04:24:02 +0000
+++ b/NEWS	2009-06-09 06:26:41 +0000
@@ -69,6 +69,9 @@
 * Better message in ``bzr add`` output suggesting using ``bzr ignored`` to
   see which files can also be added.  (Jason Spashett, #76616)
 
+* ``bzr serve`` on Windows no longer displays a traceback simply because a
+  TCP client disconnected. (Andrew Bennetts)
+
 * Clarify the rules for locking and fallback repositories. Fix bugs in how
   ``RemoteRepository`` was handling fallbacks along with the
   ``_real_repository``. (Andrew Bennetts, John Arbash Meinel, #375496)

=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py	2009-05-05 22:11:41 +0000
+++ b/bzrlib/smart/medium.py	2009-06-09 02:57:01 +0000
@@ -285,11 +285,8 @@
         self._push_back(protocol.unused_data)
 
     def _read_bytes(self, desired_count):
-        # We ignore the desired_count because on sockets it's more efficient to
-        # read large chunks (of _MAX_READ_SIZE bytes) at a time.
-        bytes = osutils.until_no_eintr(self.socket.recv, _MAX_READ_SIZE)
-        self._report_activity(len(bytes), 'read')
-        return bytes
+        return _read_bytes_from_socket(
+            self.socket.recv, desired_count, self._report_activity)
 
     def terminate_due_to_error(self):
         # TODO: This should log to a server log file, but no such thing
@@ -884,19 +881,8 @@
         """See SmartClientMedium.read_bytes."""
         if not self._connected:
             raise errors.MediumNotConnected(self)
-        # We ignore the desired_count because on sockets it's more efficient to
-        # read large chunks (of _MAX_READ_SIZE bytes) at a time.
-        try:
-            bytes = osutils.until_no_eintr(self._socket.recv, _MAX_READ_SIZE)
-        except socket.error, e:
-            if len(e.args) and e.args[0] == errno.ECONNRESET:
-                # Callers expect an empty string in that case
-                return ''
-            else:
-                raise
-        else:
-            self._report_activity(len(bytes), 'read')
-            return bytes
+        return _read_bytes_from_socket(
+            self._socket.recv, count, self._report_activity)
 
 
 class SmartClientStreamMediumRequest(SmartClientMediumRequest):
@@ -938,3 +924,20 @@
         """
         self._medium._flush()
 
+
+def _read_bytes_from_socket(sock, desired_count, report_activity):
+    # We ignore the desired_count because on sockets it's more efficient to
+    # read large chunks (of _MAX_READ_SIZE bytes) at a time.
+    try:
+        bytes = osutils.until_no_eintr(sock, _MAX_READ_SIZE)
+    except socket.error, e:
+        if len(e.args) and e.args[0] in (errno.ECONNRESET, 10054):
+            # The connection was closed by the other side.  Callers expect an
+            # empty string to signal end-of-stream.
+            bytes = ''
+        else:
+            raise
+    else:
+        report_activity(len(bytes), 'read')
+    return bytes
+




More information about the bazaar-commits mailing list