Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotoserver.py @ 37289:5fadc63ac99f
wireproto: explicit API to create outgoing streams
It is better to create outgoing streams through the reactor so the
reactor knows about what streams are active and can track them
accordingly.
Test output changes slightly because frames from subsequent responses
no longer have the "stream begin" stream flag set because the stream
is now used across all responses.
Differential Revision: https://phab.mercurial-scm.org/D2947
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 26 Mar 2018 13:59:56 -0700 |
parents | 9bfcbe4f4745 |
children | 3d0e2cd86e05 |
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py Mon Mar 26 11:00:16 2018 -0700 +++ b/mercurial/wireprotoserver.py Mon Mar 26 13:59:56 2018 -0700 @@ -432,6 +432,8 @@ reactor = wireprotoframing.serverreactor(deferoutput=True) seencommand = False + outstream = reactor.makeoutputstream() + while True: frame = wireprotoframing.readframe(req.bodyfh) if not frame: @@ -444,8 +446,8 @@ continue elif action == 'runcommand': sentoutput = _httpv2runcommand(ui, repo, req, res, authedperm, - reqcommand, reactor, meta, - issubsequent=seencommand) + reqcommand, reactor, outstream, + meta, issubsequent=seencommand) if sentoutput: return @@ -476,7 +478,7 @@ % action) def _httpv2runcommand(ui, repo, req, res, authedperm, reqcommand, reactor, - command, issubsequent): + outstream, command, issubsequent): """Dispatch a wire protocol command made from HTTPv2 requests. The authenticated permission (``authedperm``) along with the original @@ -546,10 +548,9 @@ res.status = b'200 OK' res.headers[b'Content-Type'] = FRAMINGTYPE - stream = wireprotoframing.stream(2) if isinstance(rsp, wireprototypes.bytesresponse): - action, meta = reactor.onbytesresponseready(stream, + action, meta = reactor.onbytesresponseready(outstream, command['requestid'], rsp.data) else: