fix(gost): run TcpPing commands concurrently without config save race

When multiple TcpPing requests are sent in parallel for diagnosing
multiple remote addresses, the Go agent was processing them serially.
This caused later requests to timeout (10s) while waiting for earlier
requests to complete.

Changes:
- Only TcpPing commands run in goroutines for parallel execution
- TcpPing (read-only diagnostic) no longer triggers saveConfig()
- Other state-mutating commands remain synchronous with config save
- Add mutex to saveConfig() to protect concurrent file writes
This commit is contained in:
root
2026-02-05 06:01:36 +00:00
parent eac94a5719
commit 2a4e7777ab
2 changed files with 40 additions and 5 deletions
+6
View File
@@ -2,11 +2,17 @@ package socket
import (
"os"
"sync"
"github.com/go-gost/x/config"
)
// configMutex 保护配置文件的并发写入
var configMutex sync.Mutex
func saveConfig() {
configMutex.Lock()
defer configMutex.Unlock()
file := "gost.json"