Commit 755f675b authored by Kenton Varda's avatar Kenton Varda

An aborted userland pipe should throw DISCONNECTED, not FAILED.

Rationale: If this were a native OS pipe, closing or aborting one end would cause the other end to throw DISCONNECTED.

Note that dropping the read end of a userland pipe is implemented in terms of aborting it, which makes it even more clear that this is a disconnect scenario.
parent 8d2644cc
...@@ -951,20 +951,20 @@ private: ...@@ -951,20 +951,20 @@ private:
public: public:
Promise<size_t> tryRead(void* readBufferPtr, size_t minBytes, size_t maxBytes) override { Promise<size_t> tryRead(void* readBufferPtr, size_t minBytes, size_t maxBytes) override {
KJ_FAIL_REQUIRE("abortRead() has been called"); return KJ_EXCEPTION(DISCONNECTED, "abortRead() has been called");
} }
Promise<uint64_t> pumpTo(AsyncOutputStream& output, uint64_t amount) override { Promise<uint64_t> pumpTo(AsyncOutputStream& output, uint64_t amount) override {
KJ_FAIL_REQUIRE("abortRead() has been called"); return KJ_EXCEPTION(DISCONNECTED, "abortRead() has been called");
} }
void abortRead() override { void abortRead() override {
// ignore repeated abort // ignore repeated abort
} }
Promise<void> write(const void* buffer, size_t size) override { Promise<void> write(const void* buffer, size_t size) override {
KJ_FAIL_REQUIRE("abortRead() has been called"); return KJ_EXCEPTION(DISCONNECTED, "abortRead() has been called");
} }
Promise<void> write(ArrayPtr<const ArrayPtr<const byte>> pieces) override { Promise<void> write(ArrayPtr<const ArrayPtr<const byte>> pieces) override {
KJ_FAIL_REQUIRE("abortRead() has been called"); return KJ_EXCEPTION(DISCONNECTED, "abortRead() has been called");
} }
Maybe<Promise<uint64_t>> tryPumpFrom(AsyncInputStream& input, uint64_t amount) override { Maybe<Promise<uint64_t>> tryPumpFrom(AsyncInputStream& input, uint64_t amount) override {
// There might not actually be any data in `input`, in which case a pump wouldn't actually // There might not actually be any data in `input`, in which case a pump wouldn't actually
...@@ -984,7 +984,9 @@ private: ...@@ -984,7 +984,9 @@ private:
return uint64_t(0); return uint64_t(0);
} else { } else {
// There was data in the input. The pump would have thrown. // There was data in the input. The pump would have thrown.
KJ_FAIL_REQUIRE("abortRead() has been called"); kj::throwRecoverableException(
KJ_EXCEPTION(DISCONNECTED, "abortRead() has been called"));
return uint64_t(0);
} }
}); });
} }
......
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