diff options
author | Blas Rodriguez Irizar <rodrigblas@gmail.com> | 2020-12-02 22:58:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-02 22:58:28 +0100 |
commit | a6051a61ec5c96113f4b543de3ec55431695347a (patch) | |
tree | 1a4d4bcc017f6a61a652505b1edd4a3bf36ea1ab /tokio/src | |
parent | a8e0f0a919663b210627c132d6af3e19a95d8037 (diff) |
sync: make add_permits panic with usize::MAX >> 3 permits (#3188)
Diffstat (limited to 'tokio/src')
-rw-r--r-- | tokio/src/sync/batch_semaphore.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tokio/src/sync/batch_semaphore.rs b/tokio/src/sync/batch_semaphore.rs index 0b50e4f7..8736971a 100644 --- a/tokio/src/sync/batch_semaphore.rs +++ b/tokio/src/sync/batch_semaphore.rs @@ -253,9 +253,9 @@ impl Semaphore { } if rem > 0 && is_empty { - let permits = rem << Self::PERMIT_SHIFT; + let permits = rem; assert!( - permits < Self::MAX_PERMITS, + permits <= Self::MAX_PERMITS, "cannot add more than MAX_PERMITS permits ({})", Self::MAX_PERMITS ); |