mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
fix(grpc/client): protect GetGrpcClient with _clientMux lock to avoid race during singleton init
This commit is contained in:
@@ -1059,6 +1059,9 @@ var _clientOnce sync.Once
|
||||
var _clientMux sync.Mutex
|
||||
|
||||
func GetGrpcClient() *GrpcClient {
|
||||
_clientMux.Lock()
|
||||
defer _clientMux.Unlock()
|
||||
|
||||
_clientOnce.Do(func() {
|
||||
_client = newGrpcClient()
|
||||
go _client.Start()
|
||||
|
||||
Reference in New Issue
Block a user