summaryrefslogtreecommitdiff
path: root/src/stream_base-inl.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-02-13 01:23:50 +0100
committerAnna Henningsen <anna@addaleax.net>2018-03-15 12:53:13 +0100
commit67f1d76956a8a5da9875b113371c8786ad579086 (patch)
tree220df0ab56ebc499c1edec20fe7b90449189d44b /src/stream_base-inl.h
parentf7f1437d44f3e4b745e36540a752065cc58d993b (diff)
downloadandroid-node-v8-67f1d76956a8a5da9875b113371c8786ad579086.tar.gz
android-node-v8-67f1d76956a8a5da9875b113371c8786ad579086.tar.bz2
android-node-v8-67f1d76956a8a5da9875b113371c8786ad579086.zip
src: introduce native-layer stream piping
Provide a way to create pipes between native `StreamBase` instances that acts more directly than a `.pipe()` call would. PR-URL: https://github.com/nodejs/node/pull/18936 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/stream_base-inl.h')
-rw-r--r--src/stream_base-inl.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h
index f0d522a7b0..7523b3a545 100644
--- a/src/stream_base-inl.h
+++ b/src/stream_base-inl.h
@@ -67,8 +67,14 @@ inline void StreamListener::OnStreamAfterWrite(WriteWrap* w, int status) {
inline StreamResource::~StreamResource() {
while (listener_ != nullptr) {
- listener_->OnStreamDestroy();
- RemoveStreamListener(listener_);
+ StreamListener* listener = listener_;
+ listener->OnStreamDestroy();
+ // Remove the listener if it didn’t remove itself. This makes the logic
+ // logic in `OnStreamDestroy()` implementations easier, because they
+ // may call generic cleanup functions which can just remove the
+ // listener unconditionally.
+ if (listener == listener_)
+ RemoveStreamListener(listener_);
}
}