src: ensure no more platform foreground tasks after Deinit

Node first calls `Isolate::Dispose`, then
`NodePlatform::UnregisterIsolate`.
This again calls `PerIsolatePlatformData::Shutdown`, which (before this
patch) called `FlushForegroundTasksInternal`, which might call
`RunForegroundTask` if it finds foreground tasks to be executed. This
will fail however, since `Isolate::GetCurrent` was already reset during
`Isolate::Dispose`.
Hence remove the check to `FlushForegroundTasksInternal` and add checks
instead that no more foreground tasks are scheduled.

Refs: https://github.com/v8/node/pull/86

PR-URL: https://github.com/nodejs/node/pull/25653
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Clemens Hammacher 2019-01-22 13:44:33 +01:00 committed by Anna Henningsen
parent 5109e42629
commit bafd80883c
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -265,7 +265,8 @@ void PerIsolatePlatformData::Shutdown() {
if (flush_tasks_ == nullptr)
return;
while (FlushForegroundTasksInternal()) {}
CHECK_NULL(foreground_delayed_tasks_.Pop());
CHECK_NULL(foreground_tasks_.Pop());
CancelPendingDelayedTasks();
uv_close(reinterpret_cast<uv_handle_t*>(flush_tasks_),