Skip to content

Commit 89ff4e3

Browse files
committed
fix(connection): add mutex lock for thread-safe access to local connections
1 parent fb65003 commit 89ff4e3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

core/dbio/connection/connection_local.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"sort"
88
"strings"
9+
"sync"
910
"time"
1011

1112
"github.com/flarco/g"
@@ -79,11 +80,15 @@ var (
7980
localConns ConnEntries
8081
localConnsTs time.Time
8182
localConnsExclude string
83+
localConnsMux sync.Mutex
8284
)
8385

8486
type LocalConnsExclude string
8587

8688
func GetLocalConns(options ...any) ConnEntries {
89+
localConnsMux.Lock()
90+
defer localConnsMux.Unlock()
91+
8792
defer func() { localConnsExclude = "" }() // clear if set
8893
force := false
8994

0 commit comments

Comments
 (0)