message: Just check once before actual start
diff: @@ -177,11 +177,8 @@ impl Inner {
  let latency = ServerLatency::new();
  let barrier = barrier.clone();
  - tokio::spawn(
  // Check every DEFAULT_CHECK_INTERVAL_SEC seconds
  - async move {
  - let start_time = Instant::now();
  -
  + tokio::spawn(async move {
  debug!(
  "{:?} server {} latency ping task initializing",
  server_type,
  @@ -191,30 +188,7 @@ impl Inner {
  // Quickly collect some latency data
  //
  // Maximum wait duration: DEFAULT_CHECK_TIMEOUT_SEC
  - while Instant::now() - start_time < Duration::from_secs(DEFAULT_CHECK_TIMEOUT_SEC) {
  - let mut succ = false;
  -
  - let score = match Inner::check_delay(&*sc, &*context, server_type).await {
  - Ok(d) => {
  - succ = true;
  - latency.push(Score::Latency(d))
  - }
  - Err(..) => {
  - latency.push(Score::Errored) // Penalty
  - }
  - };
  - debug!(
  - "updated remote {:?} server {} (score: {})",
  - server_type,
  - sc.config.addr(),
  - score
  - );
  - sc.score.store(score, Ordering::Release);
  -
  - if succ {
  - break;
  - }
  - }
  + Inner::check_update_score(&latency, &*sc, &*context, server_type).await;
  // Wait until all the other tasks are finished initializing
  barrier.wait().await;
  @@ -228,18 +202,7 @@ impl Inner {
  while context.server_running() {
  // First round may be failed, plugins are started asynchronously
  -
  - let score = match Inner::check_delay(&*sc, &*context, server_type).await {
  - Ok(d) => latency.push(Score::Latency(d)),
  - Err(..) => latency.push(Score::Errored), // Penalty
  - };
  - debug!(
  - "updated remote {:?} server {} (score: {})",
  - server_type,
  - sc.config.addr(),
  - score
  - );
  - sc.score.store(score, Ordering::Release);
  + Inner::check_update_score(&latency, &*sc, &*context, server_type).await;
  time::delay_for(Duration::from_secs(DEFAULT_CHECK_INTERVAL_SEC)).await;
  }
  @@ -249,8 +212,7 @@ impl Inner {
  server_type,
  sc.config.addr()
  );
  - },
  - );
  + });
  }
  if check_required {
  @@ -263,6 +225,20 @@ impl Inner {
  }
  }
  + async fn check_update_score(latency: &ServerLatency, sc: &Server, context: &Context, server_type: ServerType) {
  + let score = match Inner::check_delay(&*sc, &*context, server_type).await {
  + Ok(d) => latency.push(Score::Latency(d)),
  + Err(..) => latency.push(Score::Errored), // Penalty
  + };
  + debug!(
  + "updated remote {:?} server {} (score: {})",
  + server_type,
  + sc.config.addr(),
  + score
  + );
  + sc.score.store(score, Ordering::Release);
  + }
  +
  async fn check_request_tcp(sc: Arc<ServerConfig>, context: &Context) -> io::Result<()> {
  static GET_BODY: &[u8] =
  b"GET /generate_204 HTTP/1.1\r\nHost: dl.google.com\r\nConnection: close\r\nAccept: */*\r\n\r\n";
  