Fix Rate limiter panics when periods under 1 second are used
This commit is contained in:
@@ -17,6 +17,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
|
||||
- Disabled aliases continue receiving messages.
|
||||
- JMAP for File Storage: `FileNode/get` returns a stale state string.
|
||||
- Make `SieveSystemInterpreter.defaultReturnPath` and `MtaQueueQuota.match` optional expressions.
|
||||
- Rate limiter panics when periods under 1 second are used.
|
||||
|
||||
## [0.16.7] - 2026-05-28
|
||||
|
||||
|
||||
@@ -301,8 +301,9 @@ impl InMemoryStore {
|
||||
soft_check: bool,
|
||||
) -> trc::Result<Option<u64>> {
|
||||
let now = now();
|
||||
let range_start = now / rate.period.as_secs();
|
||||
let range_end = (range_start * rate.period.as_secs()) + rate.period.as_secs();
|
||||
let period = rate.period.as_secs().max(1);
|
||||
let range_start = now / period;
|
||||
let range_end = (range_start * period) + period;
|
||||
let expires_in = range_end - now;
|
||||
|
||||
let mut bucket = Vec::with_capacity(key.len() + U64_LEN + 1);
|
||||
|
||||
Reference in New Issue
Block a user