summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-30 16:13:07 -0400
committerAnna Henningsen <anna@addaleax.net>2018-10-08 20:06:45 -0700
commite688fe6b7e60d3dd50f0aa922a1ab74d85cb39b5 (patch)
treeaa455d2514f6b98acbb40cc64d2d7b2bd6d9b446 /test
parentc001ba65753f3eb41ecd8df3b013126593d95247 (diff)
downloadandroid-node-v8-e688fe6b7e60d3dd50f0aa922a1ab74d85cb39b5.tar.gz
android-node-v8-e688fe6b7e60d3dd50f0aa922a1ab74d85cb39b5.tar.bz2
android-node-v8-e688fe6b7e60d3dd50f0aa922a1ab74d85cb39b5.zip
zlib: simplify flushing mechanism
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 ```js 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. PR-URL: https://github.com/nodejs/node/pull/23186 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-zlib-flush-drain.js2
-rw-r--r--test/parallel/test-zlib-write-after-flush.js2
2 files changed, 2 insertions, 2 deletions
diff --git a/test/parallel/test-zlib-flush-drain.js b/test/parallel/test-zlib-flush-drain.js
index 0619eecf3c..a470e32090 100644
--- a/test/parallel/test-zlib-flush-drain.js
+++ b/test/parallel/test-zlib-flush-drain.js
@@ -44,5 +44,5 @@ process.once('exit', function() {
assert.strictEqual(
drainCount, 1);
assert.strictEqual(
- flushCount, 2);
+ flushCount, 1);
});
diff --git a/test/parallel/test-zlib-write-after-flush.js b/test/parallel/test-zlib-write-after-flush.js
index 2ba6ba4550..6d8d787343 100644
--- a/test/parallel/test-zlib-write-after-flush.js
+++ b/test/parallel/test-zlib-write-after-flush.js
@@ -35,7 +35,7 @@ gunz.setEncoding('utf8');
gunz.on('data', (c) => output += c);
gunz.on('end', common.mustCall(() => {
assert.strictEqual(output, input);
- assert.strictEqual(gzip._flushFlag, zlib.constants.Z_NO_FLUSH);
+ assert.strictEqual(gzip._nextFlush, -1);
}));
// make sure that flush/write doesn't trigger an assert failure