Patchwork [1,of,2,STABLE] wireprotov2peer: always return a bool from _processredirect()

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 28, 2018, 8:56 p.m.
Message ID <94b0d0f996e11aece0d6.1543438581@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/36866/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 28, 2018, 8:56 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1543430263 28800
#      Wed Nov 28 10:37:43 2018 -0800
# Branch stable
# Node ID 94b0d0f996e11aece0d601201f074c5a9eb0e741
# Parent  25b7c4cb5de1593e16bbd7a7dafbd28baa743995
wireprotov2peer: always return a bool from _processredirect()

Without this, we may stop servicing the redirect response if the
future has already been resolved. And the future will often be
resolved very early, since many consumers iterate the decoded
CBOR object stream and expect data to lazily arrive.
Yuya Nishihara - Nov. 29, 2018, 12:21 p.m.
On Wed, 28 Nov 2018 12:56:21 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1543430263 28800
> #      Wed Nov 28 10:37:43 2018 -0800
> # Branch stable
> # Node ID 94b0d0f996e11aece0d601201f074c5a9eb0e741
> # Parent  25b7c4cb5de1593e16bbd7a7dafbd28baa743995
> wireprotov2peer: always return a bool from _processredirect()

Queued for stable, thanks.

Patch

diff --git a/mercurial/wireprotov2peer.py b/mercurial/wireprotov2peer.py
--- a/mercurial/wireprotov2peer.py
+++ b/mercurial/wireprotov2peer.py
@@ -458,7 +458,10 @@  class clienthandler(object):
         self._redirects.append((requestid, res))
 
     def _processredirect(self, rid, res):
-        """Called to continue processing a response from a redirect."""
+        """Called to continue processing a response from a redirect.
+
+        Returns a bool indicating if the redirect is still serviceable.
+        """
         response = self._responses[rid]
 
         try:
@@ -470,7 +473,7 @@  class clienthandler(object):
                 response._oninputcomplete()
 
             if rid not in self._futures:
-                return
+                return bool(data)
 
             if response.command not in COMMAND_DECODERS:
                 self._futures[rid].set_result(response.objects())