Skip to content

Commit

Permalink
fix conn shutdown when transfer restart
Browse files Browse the repository at this point in the history
  • Loading branch information
UlricQin committed Apr 10, 2020
1 parent 0951f1f commit 80a8c69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/modules/collector/sys/funcs/clients.go
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion src/modules/collector/sys/funcs/push.go
Expand Up @@ -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)
}
Expand Down

0 comments on commit 80a8c69

Please sign in to comment.