Skip to content

Commit

Permalink
src: spin shutdown loop while immediates are pending
Browse files Browse the repository at this point in the history
This allows using `SetImmediate()` and friends at any point
during cleanup.

PR-URL: #34662
Fixes: #34657
Refs: #34572
Reviewed-By: Gabriel Schulhof <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax authored and codebytere committed Aug 11, 2020
1 parent 3132878 commit 4369c2a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,10 @@ void Environment::RunCleanup() {
initial_base_object_count_ = 0;
CleanupHandles();

while (!cleanup_hooks_.empty()) {
while (!cleanup_hooks_.empty() ||
native_immediates_.size() > 0 ||
native_immediates_threadsafe_.size() > 0 ||
native_immediates_interrupts_.size() > 0) {
// Copy into a vector, since we can't sort an unordered_set in-place.
std::vector<CleanupHookCallback> callbacks(
cleanup_hooks_.begin(), cleanup_hooks_.end());
Expand Down

0 comments on commit 4369c2a

Please sign in to comment.