Patchwork D3334: wireprotoframing: record when new stream is encountered

login
register
mail settings
Submitter phabricator
Date April 13, 2018, 9:37 p.m.
Message ID <differential-rev-PHID-DREV-hsbfx24qgxfg5wu3zcqs-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30898/
State Superseded
Headers show

Comments

phabricator - April 13, 2018, 9:37 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Without this, we choke after receiving the 2nd frame in a stream.
  Not sure how we made it this far without finding this bug.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3334

AFFECTED FILES
  mercurial/wireprotoframing.py
  tests/test-wireproto-clientreactor.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-wireproto-clientreactor.py b/tests/test-wireproto-clientreactor.py
--- a/tests/test-wireproto-clientreactor.py
+++ b/tests/test-wireproto-clientreactor.py
@@ -105,6 +105,26 @@ 
                                      'unhandled frame type'):
             sendframe(reactor, ffs(b'1 0 stream-begin text-output 0 foo'))
 
+class StreamTests(unittest.TestCase):
+    def testmultipleresponseframes(self):
+        reactor = framing.clientreactor(buffersends=False)
+
+        request, action, meta = reactor.callcommand(b'foo', {})
+
+        self.assertEqual(action, 'sendframes')
+        for f in meta['framegen']:
+            pass
+
+        action, meta = sendframe(
+            reactor,
+            ffs(b'%d 0 stream-begin 4 0 foo' % request.requestid))
+        self.assertEqual(action, 'responsedata')
+
+        action, meta = sendframe(
+            reactor,
+            ffs(b'%d 0 0 4 eos bar' % request.requestid))
+        self.assertEqual(action, 'responsedata')
+
 if __name__ == '__main__':
     import silenttestrunner
     silenttestrunner.main(__name__)
diff --git a/mercurial/wireprotoframing.py b/mercurial/wireprotoframing.py
--- a/mercurial/wireprotoframing.py
+++ b/mercurial/wireprotoframing.py
@@ -1029,6 +1029,8 @@ 
                                  'without beginning of stream flag set'),
                 }
 
+            self._incomingstreams[frame.streamid] = stream(frame.streamid)
+
         if frame.streamflags & STREAM_FLAG_ENCODING_APPLIED:
             raise error.ProgrammingError('support for decoding stream '
                                          'payloads not yet implemneted')