mercurial/wireprotov2peer.py
changeset 40019 f5a05bb48116
parent 39561 d06834e0f48e
child 40024 86b22a4cfab1
--- a/mercurial/wireprotov2peer.py	Wed Sep 26 16:07:59 2018 -0700
+++ b/mercurial/wireprotov2peer.py	Wed Sep 26 15:53:49 2018 -0700
@@ -148,6 +148,7 @@
         self._requests = {}
         self._futures = {}
         self._responses = {}
+        self._frameseof = False
 
     def callcommand(self, command, args, f):
         """Register a request to call a command.
@@ -180,18 +181,23 @@
 
         return meta['framegen']
 
-    def readframe(self, fh):
-        """Attempt to read and process a frame.
+    def readdata(self, framefh):
+        """Attempt to read data and do work.
 
-        Returns None if no frame was read. Presumably this means EOF.
+        Returns None if no data was read. Presumably this means we're
+        done with all read I/O.
         """
-        frame = wireprotoframing.readframe(fh)
-        if frame is None:
-            # TODO tell reactor?
-            return
+        if not self._frameseof:
+            frame = wireprotoframing.readframe(framefh)
+            if frame is None:
+                # TODO tell reactor?
+                self._frameseof = True
+            else:
+                self._ui.note(_('received %r\n') % frame)
+                self._processframe(frame)
 
-        self._ui.note(_('received %r\n') % frame)
-        self._processframe(frame)
+        if self._frameseof:
+            return None
 
         return True