Skip to content

Commit

Permalink
mpsc: early return for empty PermitIterator for drop logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Totodore committed Jan 2, 2024
1 parent 830188e commit ec8b537
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tokio/src/sync/mpsc/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,10 @@ impl<T> Drop for PermitIterator<'_, T> {
fn drop(&mut self) {
use chan::Semaphore;

if self.n == 0 {
return;
}

let semaphore = self.chan.semaphore();

// Add the remaining permits back to the semaphore
Expand Down

0 comments on commit ec8b537

Please sign in to comment.