mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-19 00:00:09 +02:00
runtime: fix TOCTOU issue when decreasing num_idle_threads (#7918)
This commit is contained in:
@@ -568,13 +568,13 @@ impl Inner {
|
||||
// Thread exit
|
||||
self.metrics.dec_num_threads();
|
||||
|
||||
// num_idle should now be tracked exactly, panic
|
||||
// `num_idle_threads` should now be tracked exactly, panic
|
||||
// with a descriptive message if it is not the
|
||||
// case.
|
||||
let prev_idle = self.metrics.dec_num_idle_threads();
|
||||
assert!(
|
||||
prev_idle >= self.metrics.num_idle_threads(),
|
||||
"num_idle_threads underflowed on thread exit"
|
||||
assert_ne!(
|
||||
prev_idle, 0,
|
||||
"`num_idle_threads` underflowed on thread exit"
|
||||
);
|
||||
|
||||
if shared.shutdown && self.metrics.num_threads() == 0 {
|
||||
|
||||
Reference in New Issue
Block a user