Skip to content

Commit

Permalink
SCGI: Prefill based on the size knowledge
Browse files Browse the repository at this point in the history
The netstring is approximately 460B, but if it's ever bigger, it is
buffered to minimize I/O based on the size knowledge.
  • Loading branch information
arteymix committed Dec 25, 2015
1 parent ceaf3a8 commit 74a7eed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vsgi-scgi.vala
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ namespace VSGI.SCGI {
size_t length;
var size = int.parse (reader.read_upto (":", 1, out length));

// prefill based on the size knowledge if appliable
if (size > 1 + 512) {
reader.set_buffer_size (1 + size);
reader.fill (-1);
}

// consume the semi-colon
if (reader.read_byte () != ':') {
command_line.printerr ("malformed netstring, missing ':'\n");
Expand Down

0 comments on commit 74a7eed

Please sign in to comment.