summaryrefslogtreecommitdiff
path: root/src/stream_pipe.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-06-27 12:55:33 +0200
committerAnna Henningsen <anna@addaleax.net>2018-07-16 20:20:39 +0200
commitd94950e960e41a90c4dd5030795ecfb733ff1e8e (patch)
tree873cf3035b2543276160eaf76abb0272fb476621 /src/stream_pipe.cc
parent31ecf630d05ba3a849d7b5cc1bd11ba1e5eb0785 (diff)
downloadandroid-node-v8-d94950e960e41a90c4dd5030795ecfb733ff1e8e.tar.gz
android-node-v8-d94950e960e41a90c4dd5030795ecfb733ff1e8e.tar.bz2
android-node-v8-d94950e960e41a90c4dd5030795ecfb733ff1e8e.zip
http2: fix issues with aborted `respondWithFile()`s
PR-URL: https://github.com/nodejs/node/pull/21561 Fixes: https://github.com/nodejs/node/issues/20824 Fixes: https://github.com/nodejs/node/issues/21560 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/stream_pipe.cc')
-rw-r--r--src/stream_pipe.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/stream_pipe.cc b/src/stream_pipe.cc
index bfe7d42972..e19f98e35d 100644
--- a/src/stream_pipe.cc
+++ b/src/stream_pipe.cc
@@ -57,9 +57,11 @@ void StreamPipe::Unpipe() {
if (is_closed_)
return;
- // Note that we cannot use virtual methods on `source` and `sink` here,
- // because this function can be called from their destructors via
+ // Note that we possibly cannot use virtual methods on `source` and `sink`
+ // here, because this function can be called from their destructors via
// `OnStreamDestroy()`.
+ if (!source_destroyed_)
+ source()->ReadStop();
is_closed_ = true;
is_reading_ = false;
@@ -144,7 +146,8 @@ void StreamPipe::ProcessData(size_t nread, const uv_buf_t& buf) {
is_writing_ = true;
is_reading_ = false;
res.wrap->SetAllocatedStorage(buf.base, buf.len);
- source()->ReadStop();
+ if (source() != nullptr)
+ source()->ReadStop();
}
}
@@ -183,6 +186,7 @@ void StreamPipe::WritableListener::OnStreamAfterShutdown(ShutdownWrap* w,
void StreamPipe::ReadableListener::OnStreamDestroy() {
StreamPipe* pipe = ContainerOf(&StreamPipe::readable_listener_, this);
+ pipe->source_destroyed_ = true;
if (!pipe->is_eof_) {
OnStreamRead(UV_EPIPE, uv_buf_init(nullptr, 0));
}
@@ -190,6 +194,7 @@ void StreamPipe::ReadableListener::OnStreamDestroy() {
void StreamPipe::WritableListener::OnStreamDestroy() {
StreamPipe* pipe = ContainerOf(&StreamPipe::writable_listener_, this);
+ pipe->sink_destroyed_ = true;
pipe->is_eof_ = true;
pipe->Unpipe();
}