fix conn shutdown when transfer restart

master
UlricQin 5 years ago
parent 0951f1f1af
commit 80a8c6900a

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

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

Loading…
Cancel
Save