From bd8e1bbe71794a64d00ed80695cec90bde0a939d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 20 Nov 2021 19:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96RPC=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/rpc_client.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/rpc/rpc_client.go b/internal/rpc/rpc_client.go index 82d957d8..0c42d9e7 100644 --- a/internal/rpc/rpc_client.go +++ b/internal/rpc/rpc_client.go @@ -27,7 +27,7 @@ type RPCClient struct { apiConfig *configs.APIConfig conns []*grpc.ClientConn - locker sync.Mutex + locker sync.RWMutex } // NewRPCClient 构造新的RPC客户端 @@ -535,7 +535,11 @@ func (this *RPCClient) APIContext(apiNodeId int64) context.Context { // UpdateConfig 修改配置 func (this *RPCClient) UpdateConfig(config *configs.APIConfig) error { this.apiConfig = config - return this.init() + + this.locker.Lock() + err := this.init() + this.locker.Unlock() + return err } // 初始化