File tree 2 files changed +6
-8
lines changed
crates/shadowsocks-service/src/local/loadbalancing
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -823,14 +823,12 @@ impl PingChecker {
823
823
ServerType :: Udp => self . server . udp_score ( ) ,
824
824
} ;
825
825
826
- let score = match self . check_delay ( ) . await {
826
+ let ( score, stat_data ) = match self . check_delay ( ) . await {
827
827
Ok ( d) => server_score. push_score ( Score :: Latency ( d) ) . await ,
828
828
// Penalty
829
829
Err ( ..) => server_score. push_score ( Score :: Errored ) . await ,
830
830
} ;
831
831
832
- let stat_data = server_score. stat_data ( ) . await ;
833
-
834
832
if stat_data. fail_rate > 0.5 {
835
833
warn ! (
836
834
"balancer: checked & updated remote {} server {} (score: {}), {:?}" ,
Original file line number Diff line number Diff line change @@ -40,17 +40,17 @@ impl ServerScore {
40
40
}
41
41
42
42
/// Append a `Score` into statistic and recalculate score of the server
43
- pub async fn push_score ( & self , score : Score ) -> u32 {
44
- let updated_score = {
43
+ pub async fn push_score ( & self , score : Score ) -> ( u32 , ServerStatData ) {
44
+ let ( updated_score, data ) = {
45
45
let mut stat = self . stat_data . lock ( ) . await ;
46
- stat. push_score ( score)
46
+ ( stat. push_score ( score) , stat . data ( ) . clone ( ) )
47
47
} ;
48
48
self . score . store ( updated_score, Ordering :: Release ) ;
49
- updated_score
49
+ ( updated_score, data )
50
50
}
51
51
52
52
/// Report request failure of this server, which will eventually records an `Errored` score
53
- pub async fn report_failure ( & self ) -> u32 {
53
+ pub async fn report_failure ( & self ) -> ( u32 , ServerStatData ) {
54
54
self . push_score ( Score :: Errored ) . await
55
55
}
56
56
You can’t perform that action at this time.
0 commit comments