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 committed Sep 22, 2020
1 parent 264f003 commit 01107cc
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 @@ -604,7 +604,10 @@ void Environment::RunCleanup() {
"RunCleanup", this);
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 01107cc

Please sign in to comment.