src: fix closing weak HandleWrap
s on GC
In 0af62aae07ccbb3783030367ffe4, this was overlooked, with it possibly leading to hard crashes. Refs: https://github.com/nodejs/node/pull/29317 PR-URL: https://github.com/nodejs/node/pull/29640 Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
f634f37be0
commit
e74f30894c
@ -72,11 +72,11 @@ void HandleWrap::Close(Local<Value> close_callback) {
|
|||||||
if (state_ != kInitialized)
|
if (state_ != kInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CHECK_EQ(false, persistent().IsEmpty());
|
|
||||||
uv_close(handle_, OnClose);
|
uv_close(handle_, OnClose);
|
||||||
state_ = kClosing;
|
state_ = kClosing;
|
||||||
|
|
||||||
if (!close_callback.IsEmpty() && close_callback->IsFunction()) {
|
if (!close_callback.IsEmpty() && close_callback->IsFunction() &&
|
||||||
|
!persistent().IsEmpty()) {
|
||||||
object()->Set(env()->context(),
|
object()->Set(env()->context(),
|
||||||
env()->handle_onclose_symbol(),
|
env()->handle_onclose_symbol(),
|
||||||
close_callback).Check();
|
close_callback).Check();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Flags: --expose-gc
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
@ -97,3 +98,7 @@ const {
|
|||||||
}
|
}
|
||||||
spinAWhile();
|
spinAWhile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure that the histogram instances can be garbage-collected without
|
||||||
|
// and not just implictly destroyed when the Environment is torn down.
|
||||||
|
process.on('exit', global.gc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user