diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-10-12 06:57:42 -0700 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2017-10-21 09:49:02 -0400 |
commit | a627c5fc136b3233959e8e1bff90ae4b2d0ec322 (patch) | |
tree | 483d3bbe80573974a1e68e4b64b544051603e54c /src/tls_wrap.cc | |
parent | aaf2a1c2264fffd6eea82fe3778f41ac046e6349 (diff) | |
download | android-node-v8-a627c5fc136b3233959e8e1bff90ae4b2d0ec322.tar.gz android-node-v8-a627c5fc136b3233959e8e1bff90ae4b2d0ec322.tar.bz2 android-node-v8-a627c5fc136b3233959e8e1bff90ae4b2d0ec322.zip |
net: fix timeouts during long writes
Add updateWriteQueueSize which updates and returns queue size
(net & tls). Make _onTimeout check whether an active write
is ongoing and if so, call _unrefTimer rather than emitting
a timeout event.
Add http & https test that checks whether long-lasting (but
active) writes timeout or can finish writing as expected.
PR-URL: https://github.com/nodejs/node/pull/15791
Fixes: https://github.com/nodejs/node/issues/15082
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'src/tls_wrap.cc')
-rw-r--r-- | src/tls_wrap.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 0da332f16e..63e3494047 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -932,6 +932,15 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { #endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB +void TLSWrap::UpdateWriteQueueSize(const FunctionCallbackInfo<Value>& args) { + TLSWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + + uint32_t write_queue_size = wrap->UpdateWriteQueueSize(); + args.GetReturnValue().Set(write_queue_size); +} + + void TLSWrap::Initialize(Local<Object> target, Local<Value> unused, Local<Context> context) { @@ -958,6 +967,7 @@ void TLSWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "enableSessionCallbacks", EnableSessionCallbacks); env->SetProtoMethod(t, "destroySSL", DestroySSL); env->SetProtoMethod(t, "enableCertCb", EnableCertCb); + env->SetProtoMethod(t, "updateWriteQueueSize", UpdateWriteQueueSize); StreamBase::AddMethods<TLSWrap>(env, t, StreamBase::kFlagHasWritev); SSLWrap<TLSWrap>::AddMethods(env, t); |