Commit 889d7583 authored by Kenton Varda's avatar Kenton Varda

Fix another AsyncPipe bug.

parent 76e35a7c
......@@ -1642,6 +1642,25 @@ KJ_TEST("Userland pipe tryPumpFrom to pumpTo for same amount fulfills simultaneo
KJ_EXPECT(pumpPromise2.wait(ws) == 6);
}
KJ_TEST("Userland pipe multi-part write doesn't quit early") {
kj::EventLoop loop;
WaitScope ws(loop);
auto pipe = newOneWayPipe();
auto readPromise = expectRead(*pipe.in, "foo");
kj::ArrayPtr<const byte> pieces[2] = { "foobar"_kj.asBytes(), "baz"_kj.asBytes() };
auto writePromise = pipe.out->write(pieces);
readPromise.wait(ws);
KJ_EXPECT(!writePromise.poll(ws));
expectRead(*pipe.in, "bar").wait(ws);
KJ_EXPECT(!writePromise.poll(ws));
expectRead(*pipe.in, "baz").wait(ws);
writePromise.wait(ws);
}
constexpr static auto TEE_MAX_CHUNK_SIZE = 1 << 14;
// AsyncTee::MAX_CHUNK_SIZE, 16k as of this writing
......
......@@ -692,7 +692,7 @@ private:
// Unfortunately we have to execute a separate write() for the remaining part of this
// piece, because we can't modify the pieces array.
auto promise = pipe.write(restOfPiece.begin(), restOfPiece.size());
if (pieces.size() > 0) {
if (pieces.size() == 0) {
// No more pieces so that's it.
return kj::mv(promise);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment