Skip to content

Commit

Permalink
Instant subtraction may overflow
Browse files Browse the repository at this point in the history
- ServerStat::push_score may crash when system just starts
  • Loading branch information
zonyitoo committed Jan 31, 2022
1 parent 73ad85d commit 7eb76af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
33 changes: 20 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shadowsocks-rust"
version = "1.13.0"
version = "1.13.1"
authors = ["Shadowsocks Contributors"]
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
repository = "https://github.com/shadowsocks/shadowsocks-rust"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ impl ServerStat {
self.latency_queue.push_back((score, now));

// Removes stats that are not in the check window
let windows_left = now - self.check_window;
while let Some((_, inst)) = self.latency_queue.front() {
if *inst < windows_left {
if now - *inst > self.check_window {
self.latency_queue.pop_front();
} else {
break;
Expand Down

0 comments on commit 7eb76af

Please sign in to comment.