mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-07 00:13:33 +00:00
fix(local): ServerScore push_score maintain compatibility
This commit is contained in:
@@ -824,9 +824,9 @@ impl PingChecker {
|
||||
};
|
||||
|
||||
let (score, stat_data) = match self.check_delay().await {
|
||||
Ok(d) => server_score.push_score(Score::Latency(d)).await,
|
||||
Ok(d) => server_score.push_score_fetch_statistic(Score::Latency(d)).await,
|
||||
// Penalty
|
||||
Err(..) => server_score.push_score(Score::Errored).await,
|
||||
Err(..) => server_score.push_score_fetch_statistic(Score::Errored).await,
|
||||
};
|
||||
|
||||
if stat_data.fail_rate > 0.5 {
|
||||
|
||||
@@ -40,7 +40,17 @@ impl ServerScore {
|
||||
}
|
||||
|
||||
/// Append a `Score` into statistic and recalculate score of the server
|
||||
pub async fn push_score(&self, score: Score) -> (u32, ServerStatData) {
|
||||
pub async fn push_score(&self, score: Score) -> u32 {
|
||||
let updated_score = {
|
||||
let mut stat = self.stat_data.lock().await;
|
||||
stat.push_score(score)
|
||||
};
|
||||
self.score.store(updated_score, Ordering::Release);
|
||||
updated_score
|
||||
}
|
||||
|
||||
/// Append a `Score` into statistic and recalculate score of the server
|
||||
pub async fn push_score_fetch_statistic(&self, score: Score) -> (u32, ServerStatData) {
|
||||
let (updated_score, data) = {
|
||||
let mut stat = self.stat_data.lock().await;
|
||||
(stat.push_score(score), stat.data().clone())
|
||||
@@ -50,7 +60,7 @@ impl ServerScore {
|
||||
}
|
||||
|
||||
/// Report request failure of this server, which will eventually records an `Errored` score
|
||||
pub async fn report_failure(&self) -> (u32, ServerStatData) {
|
||||
pub async fn report_failure(&self) -> u32 {
|
||||
self.push_score(Score::Errored).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user