tls_wrap: do not hold persistent ref to parent
Hold non-persistent reference in JS, rather than in C++ to avoid cycles. PR-URL: https://github.com/iojs/io.js/pull/1078 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Родитель
dccb69a21a
Коммит
c09c90c1a9
|
@ -286,6 +286,7 @@ TLSSocket.prototype._wrapHandle = function(handle) {
|
||||||
tls.createSecureContext();
|
tls.createSecureContext();
|
||||||
res = tls_wrap.wrap(handle, context.context, options.isServer);
|
res = tls_wrap.wrap(handle, context.context, options.isServer);
|
||||||
res._parent = handle;
|
res._parent = handle;
|
||||||
|
res._secureContext = context;
|
||||||
res.reading = handle.reading;
|
res.reading = handle.reading;
|
||||||
Object.defineProperty(handle, 'reading', {
|
Object.defineProperty(handle, 'reading', {
|
||||||
get: function readingGetter() {
|
get: function readingGetter() {
|
||||||
|
|
|
@ -37,17 +37,14 @@ using v8::Value;
|
||||||
TLSWrap::TLSWrap(Environment* env,
|
TLSWrap::TLSWrap(Environment* env,
|
||||||
Kind kind,
|
Kind kind,
|
||||||
StreamBase* stream,
|
StreamBase* stream,
|
||||||
Handle<Object> stream_obj,
|
SecureContext* sc)
|
||||||
Handle<Object> sc)
|
: SSLWrap<TLSWrap>(env, sc, kind),
|
||||||
: SSLWrap<TLSWrap>(env, Unwrap<SecureContext>(sc), kind),
|
|
||||||
StreamBase(env),
|
StreamBase(env),
|
||||||
AsyncWrap(env,
|
AsyncWrap(env,
|
||||||
env->tls_wrap_constructor_function()->NewInstance(),
|
env->tls_wrap_constructor_function()->NewInstance(),
|
||||||
AsyncWrap::PROVIDER_TLSWRAP),
|
AsyncWrap::PROVIDER_TLSWRAP),
|
||||||
sc_(Unwrap<SecureContext>(sc)),
|
sc_(sc),
|
||||||
sc_handle_(env->isolate(), sc),
|
|
||||||
stream_(stream),
|
stream_(stream),
|
||||||
stream_handle_(env->isolate(), stream_obj),
|
|
||||||
enc_in_(nullptr),
|
enc_in_(nullptr),
|
||||||
enc_out_(nullptr),
|
enc_out_(nullptr),
|
||||||
clear_in_(nullptr),
|
clear_in_(nullptr),
|
||||||
|
@ -84,9 +81,6 @@ TLSWrap::~TLSWrap() {
|
||||||
clear_in_ = nullptr;
|
clear_in_ = nullptr;
|
||||||
|
|
||||||
sc_ = nullptr;
|
sc_ = nullptr;
|
||||||
sc_handle_.Reset();
|
|
||||||
stream_handle_.Reset();
|
|
||||||
persistent().Reset();
|
|
||||||
|
|
||||||
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
||||||
sni_context_.Reset();
|
sni_context_.Reset();
|
||||||
|
@ -196,9 +190,9 @@ void TLSWrap::Wrap(const FunctionCallbackInfo<Value>& args) {
|
||||||
});
|
});
|
||||||
CHECK_NE(stream, nullptr);
|
CHECK_NE(stream, nullptr);
|
||||||
|
|
||||||
TLSWrap* res = new TLSWrap(env, kind, stream, stream_obj, sc);
|
TLSWrap* res = new TLSWrap(env, kind, stream, Unwrap<SecureContext>(sc));
|
||||||
|
|
||||||
args.GetReturnValue().Set(res->persistent());
|
args.GetReturnValue().Set(res->object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,7 @@ class TLSWrap : public crypto::SSLWrap<TLSWrap>,
|
||||||
TLSWrap(Environment* env,
|
TLSWrap(Environment* env,
|
||||||
Kind kind,
|
Kind kind,
|
||||||
StreamBase* stream,
|
StreamBase* stream,
|
||||||
v8::Handle<v8::Object> stream_obj,
|
crypto::SecureContext* sc);
|
||||||
v8::Handle<v8::Object> sc);
|
|
||||||
|
|
||||||
static void SSLInfoCallback(const SSL* ssl_, int where, int ret);
|
static void SSLInfoCallback(const SSL* ssl_, int where, int ret);
|
||||||
void InitSSL();
|
void InitSSL();
|
||||||
|
@ -141,9 +140,7 @@ class TLSWrap : public crypto::SSLWrap<TLSWrap>,
|
||||||
#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
|
||||||
|
|
||||||
crypto::SecureContext* sc_;
|
crypto::SecureContext* sc_;
|
||||||
v8::Persistent<v8::Object> sc_handle_;
|
|
||||||
StreamBase* stream_;
|
StreamBase* stream_;
|
||||||
v8::Persistent<v8::Object> stream_handle_;
|
|
||||||
BIO* enc_in_;
|
BIO* enc_in_;
|
||||||
BIO* enc_out_;
|
BIO* enc_out_;
|
||||||
NodeBIO* clear_in_;
|
NodeBIO* clear_in_;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче