@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a couple of clarifying comments to the Mercurial protocol parser

Summary: See D18857. Ref T13036. See PHI275. Explain what's going on here a little better since it isn't entirely obvious and debugging these stream parsers is a gigantic pain.

Test Plan: Read text.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13036

Differential Revision: https://secure.phabricator.com/D18859

+19
+19
src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
··· 180 180 $this->state = 'arguments'; 181 181 } 182 182 } else if ($this->state == 'data-length') { 183 + 184 + // We're reading the length of a chunk of raw data. It looks like 185 + // this: 186 + // 187 + // <length-in-bytes>\n 188 + // 189 + // The length is human-readable text (for example, "4096"), and 190 + // may be 0. 191 + 183 192 $line = $this->readProtocolLine(); 184 193 if ($line === null) { 185 194 break; ··· 192 201 $this->state = 'data-bytes'; 193 202 } 194 203 } else if ($this->state == 'data-bytes') { 204 + 205 + // We're reading some known, nonzero number of raw bytes of data. 206 + 195 207 // If we don't have any more bytes on the buffer yet, just bail: 196 208 // otherwise, we'll emit a pointless and possibly harmful 0-byte data 197 209 // frame. See T13036 for discussion. ··· 202 214 $bytes = substr($this->buffer, 0, $this->expectBytes); 203 215 $this->buffer = substr($this->buffer, strlen($bytes)); 204 216 $this->expectBytes -= strlen($bytes); 217 + 218 + // NOTE: We emit a data frame as soon as we read some data. This can 219 + // cause us to repackage frames: for example, if we receive one large 220 + // frame slowly, we may emit it as several smaller frames. In theory 221 + // this is good; in practice, Mercurial never seems to select a frame 222 + // size larger than 4096 bytes naturally and this may be more 223 + // complexity and trouble than it is worth. See T13036. 205 224 206 225 $messages[] = $this->newDataMessage($bytes); 207 226