diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-12-27 19:12:13 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-01-07 22:35:59 +0100 |
commit | d5fa4de00f8d9b95daa01b39a5307e9a9da44d35 (patch) | |
tree | 72a536dc1d121fecb1c5eab49356b6d21af18145 /src/tls_wrap.h | |
parent | b171adc4d12e96f7b72155ea54a78dd1c8e5823f (diff) | |
download | node-new-d5fa4de00f8d9b95daa01b39a5307e9a9da44d35.tar.gz |
tls: refactor write queues away
The TLS implementation previously had two separate queues for
WriteWrap instances, one for currently active and one for
finishing writes (i.e. where the encrypted output is being written
to the underlying socket).
However, the streams implementation in Node doesn’t allow for
more than one write to be active at a time; effectively,
the only possible states were that:
- No write was active.
- The first write queue had one item, the second one was empty.
- Only the second write queue had one item, the first one was empty.
To reduce overhead and implementation complexity, remove these
queues, and instead store a single `WriteWrap` pointer and
keep track of whether its write callback should be called
on the next invocation of `InvokeQueued()` or not
(which is what being in the second queue previously effected).
PR-URL: https://github.com/nodejs/node/pull/17883
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/tls_wrap.h')
-rw-r--r-- | src/tls_wrap.h | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/tls_wrap.h b/src/tls_wrap.h index ed047797c2..ffa4fb5b4d 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -90,19 +90,6 @@ class TLSWrap : public AsyncWrap, // Maximum number of buffers passed to uv_write() static const int kSimultaneousBufferCount = 10; - // Write callback queue's item - class WriteItem { - public: - explicit WriteItem(WriteWrap* w) : w_(w) { - } - ~WriteItem() { - w_ = nullptr; - } - - WriteWrap* w_; - ListNode<WriteItem> member_; - }; - TLSWrap(Environment* env, Kind kind, StreamBase* stream, @@ -173,9 +160,8 @@ class TLSWrap : public AsyncWrap, BIO* enc_out_; crypto::NodeBIO* clear_in_; size_t write_size_; - typedef ListHead<WriteItem, &WriteItem::member_> WriteItemList; - WriteItemList write_item_queue_; - WriteItemList pending_write_items_; + WriteWrap* current_write_ = nullptr; + bool write_callback_scheduled_ = false; bool started_; bool established_; bool shutdown_; |