Mercurial > hg
comparison mercurial/wireprotoframing.py @ 40136:3a6d6c54bd81
wireprotov2: don't emit empty frames
Staring at logs revealed the presence of empty frames that should have
contained payload. Let's stop that from happening.
Differential Revision: https://phab.mercurial-scm.org/D4925
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 05 Oct 2018 23:49:18 +0000 |
parents | 966b5f7fd30b |
children | b5bf3dd6ec5b |
comparison
equal
deleted
inserted
replaced
40135:966b5f7fd30b | 40136:3a6d6c54bd81 |
---|---|
529 # * If a chunk can be buffered without total buffered size limits | 529 # * If a chunk can be buffered without total buffered size limits |
530 # being exceeded, we do that. | 530 # being exceeded, we do that. |
531 # * If a chunk causes us to go over our buffering limit, we flush | 531 # * If a chunk causes us to go over our buffering limit, we flush |
532 # and then buffer the new chunk. | 532 # and then buffer the new chunk. |
533 | 533 |
534 if not data: | |
535 return | |
536 | |
534 if len(data) > self._maxsize: | 537 if len(data) > self._maxsize: |
535 for frame in self._flush(): | 538 for frame in self._flush(): |
536 yield frame | 539 yield frame |
537 | 540 |
538 # Now emit frames for the big chunk. | 541 # Now emit frames for the big chunk. |
570 payload = b''.join(self._chunks) | 573 payload = b''.join(self._chunks) |
571 assert len(payload) <= self._maxsize | 574 assert len(payload) <= self._maxsize |
572 | 575 |
573 self._chunks[:] = [] | 576 self._chunks[:] = [] |
574 self._chunkssize = 0 | 577 self._chunkssize = 0 |
578 | |
579 if not payload: | |
580 return | |
575 | 581 |
576 yield self._stream.makeframe( | 582 yield self._stream.makeframe( |
577 self._requestid, | 583 self._requestid, |
578 typeid=FRAME_TYPE_COMMAND_RESPONSE, | 584 typeid=FRAME_TYPE_COMMAND_RESPONSE, |
579 flags=FLAG_COMMAND_RESPONSE_CONTINUATION, | 585 flags=FLAG_COMMAND_RESPONSE_CONTINUATION, |