Skip to content

Commit ec3dd2d

Browse files
author
Marvin Zhang
committed
fix(grpc/client): protect GetGrpcClient with _clientMux lock to avoid race during singleton init
1 parent 2dfc667 commit ec3dd2d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/grpc/client/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,9 @@ var _clientOnce sync.Once
10591059
var _clientMux sync.Mutex
10601060

10611061
func GetGrpcClient() *GrpcClient {
1062+
_clientMux.Lock()
1063+
defer _clientMux.Unlock()
1064+
10621065
_clientOnce.Do(func() {
10631066
_client = newGrpcClient()
10641067
go _client.Start()

0 commit comments

Comments
 (0)