Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de7403f

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: cleanup per-isolate state on platform on isolate unregister
Clean up once all references to an `Isolate*` are gone from the `NodePlatform`, rather than waiting for the `PerIsolatePlatformData` struct to be deleted since there may be cyclic references between that struct and the individual tasks. PR-URL: #20876 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
1 parent 9047c81 commit de7403f
Copy full SHA for de7403f

File tree

Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-0
lines changed
Open diff view settings
Collapse file

‎src/node_platform.cc‎

Copy file name to clipboardExpand all lines: src/node_platform.cc
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ void PerIsolatePlatformData::PostIdleTask(std::unique_ptr<v8::IdleTask> task) {
8282
}
8383

8484
void PerIsolatePlatformData::PostTask(std::unique_ptr<Task> task) {
85+
CHECK_NE(flush_tasks_, nullptr);
8586
foreground_tasks_.Push(std::move(task));
8687
uv_async_send(flush_tasks_);
8788
}
8889

8990
void PerIsolatePlatformData::PostDelayedTask(
9091
std::unique_ptr<Task> task, double delay_in_seconds) {
92+
CHECK_NE(flush_tasks_, nullptr);
9193
std::unique_ptr<DelayedTask> delayed(new DelayedTask());
9294
delayed->task = std::move(task);
9395
delayed->platform_data = shared_from_this();
@@ -97,13 +99,21 @@ void PerIsolatePlatformData::PostDelayedTask(
9799
}
98100

99101
PerIsolatePlatformData::~PerIsolatePlatformData() {
102+
Shutdown();
103+
}
104+
105+
void PerIsolatePlatformData::Shutdown() {
106+
if (flush_tasks_ == nullptr)
107+
return;
108+
100109
while (FlushForegroundTasksInternal()) {}
101110
CancelPendingDelayedTasks();
102111

103112
uv_close(reinterpret_cast<uv_handle_t*>(flush_tasks_),
104113
[](uv_handle_t* handle) {
105114
delete reinterpret_cast<uv_async_t*>(handle);
106115
});
116+
flush_tasks_ = nullptr;
107117
}
108118

109119
void PerIsolatePlatformData::ref() {
@@ -144,6 +154,7 @@ void NodePlatform::UnregisterIsolate(IsolateData* isolate_data) {
144154
std::shared_ptr<PerIsolatePlatformData> existing = per_isolate_[isolate];
145155
CHECK(existing);
146156
if (existing->unref() == 0) {
157+
existing->Shutdown();
147158
per_isolate_.erase(isolate);
148159
}
149160
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.