mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +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
|
// Thread exit
|
||||||
self.metrics.dec_num_threads();
|
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
|
// with a descriptive message if it is not the
|
||||||
// case.
|
// case.
|
||||||
let prev_idle = self.metrics.dec_num_idle_threads();
|
let prev_idle = self.metrics.dec_num_idle_threads();
|
||||||
assert!(
|
assert_ne!(
|
||||||
prev_idle >= self.metrics.num_idle_threads(),
|
prev_idle, 0,
|
||||||
"num_idle_threads underflowed on thread exit"
|
"`num_idle_threads` underflowed on thread exit"
|
||||||
);
|
);
|
||||||
|
|
||||||
if shared.shutdown && self.metrics.num_threads() == 0 {
|
if shared.shutdown && self.metrics.num_threads() == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user