fix conn shutdown when transfer restart

This commit is contained in:
UlricQin 2020-04-10 16:53:12 +08:00
parent 0951f1f1af
commit 80a8c6900a
2 changed files with 7 additions and 1 deletions

View File

@ -43,3 +43,9 @@ func (rcc *RpcClientContainer) Put(addr string, client *rpc.Client) bool {
rcc.M[addr] = client
return true
}
func (rcc *RpcClientContainer) Del(addr string) {
rcc.Lock()
defer rcc.Unlock()
delete(rcc.M, addr)
}

View File

@ -110,7 +110,7 @@ func rpcCall(addr string, items []*dataobj.MetricValue) (dataobj.TransferResp, e
return reply, fmt.Errorf("%s rpc call timeout", addr)
case err := <-done:
if err != nil {
rpcClients.Put(addr, nil)
rpcClients.Del(addr)
client.Close()
return reply, fmt.Errorf("%s rpc call done, but fail: %v", addr, err)
}