Reduce MeasureDelay timeout from 12s to 6s and remove unnecessary delays

This commit is contained in:
zarazaex69
2026-04-26 23:14:39 +03:00
parent 641fcb943d
commit d0161826e2
2 changed files with 4 additions and 6 deletions
+3 -3
View File
@@ -159,10 +159,10 @@ func (x *CoreController) QueryStats(tag string, direct string) int64 {
}
// MeasureDelay measures network latency to a specified URL through the current core instance
// Uses a 12-second timeout context and returns the round-trip time in milliseconds
// Uses a 6-second timeout context and returns the round-trip time in milliseconds
// An error is returned if the connection fails or returns an unexpected status
func (x *CoreController) MeasureDelay(url string) (int64, error) {
ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second)
defer cancel()
return measureInstDelay(ctx, x.coreInstance, url)
@@ -307,7 +307,7 @@ func measureInstDelay(ctx context.Context, inst *core.Instance, url string) (int
client := &http.Client{
Transport: tr,
Timeout: 5 * time.Second,
Timeout: 6 * time.Second,
}
if url == "" {
@@ -266,8 +266,7 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect
launch(Dispatchers.IO) {
val result = mainViewModel.updateConfigViaSubAll()
delay(500L)
launch(Dispatchers.Main) {
withContext(Dispatchers.Main) {
if (result.configCount > 0) {
mainViewModel.reloadServerList()
showStatus("Обновлено ${result.configCount} профилей. Запуск теста...")
@@ -276,7 +275,6 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect
}
hideLoading()
delay(500L)
showStatus("Выполняется замер задержки. Ожидаем завершения...")
mainViewModel.testAllRealPing()
}