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 <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Sep 22, 2020
1 parent dabd04d commit 1549048
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 1549048

Please sign in to comment.