fix: ssh tunnel检测导致死锁问题调整

This commit is contained in:
meilin.huang
2025-05-27 22:56:54 +08:00
parent e0c01d4561
commit bcaa4563ac
10 changed files with 93 additions and 28 deletions

View File

@@ -25,7 +25,7 @@ func init() {
if v.Stats().TotalConns == 0 {
continue // 连接池中没有连接,跳过
}
conn, err := v.Get(context.Background())
conn, err := v.Get(context.Background(), pool.WithNoUpdateLastActive())
if err != nil {
continue // 获取连接失败,跳过
}

View File

@@ -48,7 +48,7 @@ func init() {
if v.Stats().TotalConns == 0 {
continue // 连接池中没有连接,跳过
}
conn, err := v.Get(context.Background())
conn, err := v.Get(context.Background(), pool.WithNoUpdateLastActive())
if err != nil {
continue // 获取连接失败,跳过
}

View File

@@ -2,6 +2,7 @@ package mcm
import (
"context"
"fmt"
"mayfly-go/pkg/pool"
)
@@ -51,11 +52,11 @@ func GetMachineCli(ctx context.Context, authCertName string, getMachine func(str
// 删除指定机器缓存客户端,并关闭客户端连接
func DeleteCli(id uint64) {
for _, pool := range poolGroup.AllPool() {
if pool.Stats().TotalConns == 0 {
for _, p := range poolGroup.AllPool() {
if p.Stats().TotalConns == 0 {
continue
}
conn, err := pool.Get(context.Background())
conn, err := p.Get(context.Background(), pool.WithNoUpdateLastActive())
if err != nil {
continue
}
@@ -63,4 +64,6 @@ func DeleteCli(id uint64) {
poolGroup.Close(conn.Info.AuthCertName)
}
}
// 删除隧道
tunnelPoolGroup.Close(fmt.Sprintf("machine-tunnel-%d", id))
}

View File

@@ -17,7 +17,7 @@ func init() {
if v.Stats().TotalConns == 0 {
continue // 连接池中没有连接,跳过
}
conn, err := v.Get(context.Background())
conn, err := v.Get(context.Background(), pool.WithNoUpdateLastActive())
if err != nil {
continue // 获取连接失败,跳过
}

View File

@@ -18,7 +18,7 @@ func init() {
if v.Stats().TotalConns == 0 {
continue // 连接池中没有连接,跳过
}
rc, err := v.Get(context.Background())
rc, err := v.Get(context.Background(), pool.WithNoUpdateLastActive())
if err != nil {
continue // 获取连接失败,跳过
}