GeezerVison is showing github.com — tls: zero SSL_CTX freelist for a singleUse socket · nodejs/node@1cfc455
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/_tls_common.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -133,6 +133,10 @@ exports.createSecureContext = function createSecureContext(options, context) { | 133 | 133 | } | 134 | 134 | } | 135 | 135 |
| | 136 | + // Do not keep read/write buffers in free list | | 137 | + if (options.singleUse) | | 138 | + c.context.setFreeListLength(0); | | 139 | + | 136 | 140 | return c; | 137 | 141 | }; | 138 | 142 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/_tls_wrap.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -862,6 +862,8 @@ exports.connect = function(/* [port, host], options, cb */) { | 862 | 862 | }; | 863 | 863 |
| 864 | 864 | options = util._extend(defaults, options || {}); | | 865 | + if (!options.keepAlive) | | 866 | + options.singleUse = true; | 865 | 867 |
| 866 | 868 | assert(typeof options.checkServerIdentity === 'function'); | 867 | 869 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_crypto.cc +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -265,6 +265,7 @@ void SecureContext::Initialize(Environment* env, Handle<Object> target) { | 265 | 265 | env->SetProtoMethod(t, "loadPKCS12", SecureContext::LoadPKCS12); | 266 | 266 | env->SetProtoMethod(t, "getTicketKeys", SecureContext::GetTicketKeys); | 267 | 267 | env->SetProtoMethod(t, "setTicketKeys", SecureContext::SetTicketKeys); | | 268 | + env->SetProtoMethod(t, "setFreeListLength", SecureContext::SetFreeListLength); | 268 | 269 | env->SetProtoMethod(t, "getCertificate", SecureContext::GetCertificate<true>); | 269 | 270 | env->SetProtoMethod(t, "getIssuer", SecureContext::GetCertificate<false>); | 270 | 271 |
| @@ -933,6 +934,13 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) { | 933 | 934 | } | 934 | 935 |
| 935 | 936 |
| | 937 | +void SecureContext::SetFreeListLength(const FunctionCallbackInfo<Value>& args) { | | 938 | + SecureContext* wrap = Unwrap<SecureContext>(args.Holder()); | | 939 | + | | 940 | + wrap->ctx_->freelist_max_len = args[0]->Int32Value(); | | 941 | +} | | 942 | + | | 943 | + | 936 | 944 | void SecureContext::CtxGetter(Local<String> property, | 937 | 945 | const PropertyCallbackInfo<Value>& info) { | 938 | 946 | HandleScope scope(info.GetIsolate()); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_crypto.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,6 +85,8 @@ class SecureContext : public BaseObject { | 85 | 85 | static void LoadPKCS12(const v8::FunctionCallbackInfo<v8::Value>& args); | 86 | 86 | static void GetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args); | 87 | 87 | static void SetTicketKeys(const v8::FunctionCallbackInfo<v8::Value>& args); | | 88 | + static void SetFreeListLength( | | 89 | + const v8::FunctionCallbackInfo<v8::Value>& args); | 88 | 90 | static void CtxGetter(v8::Local<v8::String> property, | 89 | 91 | const v8::PropertyCallbackInfo<v8::Value>& info); | 90 | 92 |
| |
|