Skip to content

zlib: simplify flushing mechanism

Rodrigo Muino Tomonari requested to merge github/fork/addaleax/zlib-flush into master

Previously, flushing on zlib streams was implemented through stream 'drain' handlers. This has a number of downsides; in particular, it is complex, and could lead to unpredictable behaviour, since it meant that in a sequence like

compressor.write('abc');
compressor.flush();
waitForMoreDataAsynchronously(() => {
  compressor.write('def');
});

it was not fully deterministic whether the flush happens after the second chunk is written or the first one.

This commit replaces this mechanism by one that piggy-backs along the stream’s write queue, using a “special” Buffer instance that signals that a flush is currently due.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading