GeezerVison is showing github.com — src: prevent persistent handle resource leaks · inre/node@992703f
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: node.gyp +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 371 | 371 | 'src/node_internals.h', | 372 | 372 | 'src/node_javascript.h', | 373 | 373 | 'src/node_mutex.h', | 374 | | - 'src/node_platform.h', | 375 | 374 | 'src/node_perf.h', | 376 | 375 | 'src/node_perf_common.h', | | 376 | + 'src/node_persistent.h', | | 377 | + 'src/node_platform.h', | 377 | 378 | 'src/node_root_certs.h', | 378 | 379 | 'src/node_version.h', | 379 | 380 | 'src/node_watchdog.h', | |
Collapse file Copy file name to clipboardExpand all lines: src/async_wrap.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -409,8 +409,8 @@ static void DisablePromiseHook(const FunctionCallbackInfo<Value>& args) { | 409 | 409 | class DestroyParam { | 410 | 410 | public: | 411 | 411 | double asyncId; | 412 | | - v8::Persistent<Object> target; | 413 | | - v8::Persistent<Object> propBag; | | 412 | + Persistent<Object> target; | | 413 | + Persistent<Object> propBag; | 414 | 414 | }; | 415 | 415 |
| 416 | 416 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/base_object-inl.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,7 +47,7 @@ inline BaseObject::~BaseObject() { | 47 | 47 | } | 48 | 48 |
| 49 | 49 |
| 50 | | -inline v8::Persistent<v8::Object>& BaseObject::persistent() { | | 50 | +inline Persistent<v8::Object>& BaseObject::persistent() { | 51 | 51 | return persistent_handle_; | 52 | 52 | } | 53 | 53 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/base_object.h +3-7Lines changed: 3 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 |
| 25 | 25 | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | 26 | 26 |
| | 27 | +#include "node_persistent.h" | 27 | 28 | #include "v8.h" | 28 | 29 |
| 29 | 30 | namespace node { | @@ -39,12 +40,7 @@ class BaseObject { | 39 | 40 | // persistent.IsEmpty() is true. | 40 | 41 | inline v8::Local<v8::Object> object(); | 41 | 42 |
| 42 | | - // The parent class is responsible for calling .Reset() on destruction | 43 | | - // when the persistent handle is strong because there is no way for | 44 | | - // BaseObject to know when the handle goes out of scope. | 45 | | - // Weak handles have been reset by the time the destructor runs but | 46 | | - // calling .Reset() again is harmless. | 47 | | - inline v8::Persistent<v8::Object>& persistent(); | | 43 | + inline Persistent<v8::Object>& persistent(); | 48 | 44 |
| 49 | 45 | inline Environment* env() const; | 50 | 46 |
| @@ -71,7 +67,7 @@ class BaseObject { | 71 | 67 | // position of members in memory are predictable. For more information please | 72 | 68 | // refer to `doc/guides/node-postmortem-support.md` | 73 | 69 | friend int GenDebugSymbols(); | 74 | | - v8::Persistent<v8::Object> persistent_handle_; | | 70 | + Persistent<v8::Object> persistent_handle_; | 75 | 71 | Environment* env_; | 76 | 72 | }; | 77 | 73 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/env-inl.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -550,8 +550,8 @@ void Environment::CreateImmediate(native_immediate_callback cb, | 550 | 550 | native_immediate_callbacks_.push_back({ | 551 | 551 | cb, | 552 | 552 | data, | 553 | | - std::unique_ptr<v8::Persistent<v8::Object>>(obj.IsEmpty() ? | 554 | | - nullptr : new v8::Persistent<v8::Object>(isolate_, obj)), | | 553 | + std::unique_ptr<Persistent<v8::Object>>(obj.IsEmpty() ? | | 554 | + nullptr : new Persistent<v8::Object>(isolate_, obj)), | 555 | 555 | ref | 556 | 556 | }); | 557 | 557 | immediate_info()->count_inc(1); | |
Collapse file Copy file name to clipboardExpand all lines: src/env.h +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -847,7 +847,7 @@ class Environment { | 847 | 847 | struct NativeImmediateCallback { | 848 | 848 | native_immediate_callback cb_; | 849 | 849 | void* data_; | 850 | | - std::unique_ptr<v8::Persistent<v8::Object>> keep_alive_; | | 850 | + std::unique_ptr<Persistent<v8::Object>> keep_alive_; | 851 | 851 | bool refed_; | 852 | 852 | }; | 853 | 853 | std::vector<NativeImmediateCallback> native_immediate_callbacks_; | @@ -858,8 +858,7 @@ class Environment { | 858 | 858 | v8::Local<v8::Promise> promise, | 859 | 859 | v8::Local<v8::Value> parent); | 860 | 860 |
| 861 | | -#define V(PropertyName, TypeName) \ | 862 | | - v8::Persistent<TypeName> PropertyName ## _; | | 861 | +#define V(PropertyName, TypeName) Persistent<TypeName> PropertyName ## _; | 863 | 862 | ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) | 864 | 863 | #undef V | 865 | 864 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/inspector_agent.cc -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,7 +30,6 @@ using v8::HandleScope; | 30 | 30 | using v8::Isolate; | 31 | 31 | using v8::Local; | 32 | 32 | using v8::Object; | 33 | | -using v8::Persistent; | 34 | 33 | using v8::String; | 35 | 34 | using v8::Value; | 36 | 35 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/inspector_agent.h +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -97,7 +97,7 @@ class Agent { | 97 | 97 |
| 98 | 98 | private: | 99 | 99 | void ToggleAsyncHook(v8::Isolate* isolate, | 100 | | - const v8::Persistent<v8::Function>& fn); | | 100 | + const Persistent<v8::Function>& fn); | 101 | 101 |
| 102 | 102 | node::Environment* parent_env_; | 103 | 103 | std::unique_ptr<NodeInspectorClient> client_; | @@ -109,8 +109,8 @@ class Agent { | 109 | 109 |
| 110 | 110 | bool pending_enable_async_hook_; | 111 | 111 | bool pending_disable_async_hook_; | 112 | | - v8::Persistent<v8::Function> enable_async_hook_function_; | 113 | | - v8::Persistent<v8::Function> disable_async_hook_function_; | | 112 | + Persistent<v8::Function> enable_async_hook_function_; | | 113 | + Persistent<v8::Function> disable_async_hook_function_; | 114 | 114 | }; | 115 | 115 |
| 116 | 116 | } // namespace inspector | |
Collapse file Copy file name to clipboardExpand all lines: src/inspector_js_api.cc -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,6 @@ using v8::Local; | 19 | 19 | using v8::MaybeLocal; | 20 | 20 | using v8::NewStringType; | 21 | 21 | using v8::Object; | 22 | | -using v8::Persistent; | 23 | 22 | using v8::String; | 24 | 23 | using v8::Value; | 25 | 24 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/module_wrap.h +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,11 +62,11 @@ class ModuleWrap : public BaseObject { | 62 | 62 | static ModuleWrap* GetFromModule(node::Environment*, v8::Local<v8::Module>); | 63 | 63 |
| 64 | 64 |
| 65 | | - v8::Persistent<v8::Module> module_; | 66 | | - v8::Persistent<v8::String> url_; | | 65 | + Persistent<v8::Module> module_; | | 66 | + Persistent<v8::String> url_; | 67 | 67 | bool linked_ = false; | 68 | | - std::unordered_map<std::string, v8::Persistent<v8::Promise>> resolve_cache_; | 69 | | - v8::Persistent<v8::Context> context_; | | 68 | + std::unordered_map<std::string, Persistent<v8::Promise>> resolve_cache_; | | 69 | + Persistent<v8::Context> context_; | 70 | 70 | }; | 71 | 71 |
| 72 | 72 | } // namespace loader | |
|