fix rpc conn close
This commit is contained in:
parent
761c0fae25
commit
d4b24ed573
|
@ -78,14 +78,19 @@ func rpcCall(addr string, items []*dataobj.MetricValue) (dataobj.TransferResp, e
|
|||
var reply dataobj.TransferResp
|
||||
var err error
|
||||
|
||||
affected := false
|
||||
client := rpcClients.Get(addr)
|
||||
if client == nil {
|
||||
client, err = rpcClient(addr)
|
||||
if err != nil {
|
||||
return reply, err
|
||||
} else {
|
||||
affected = rpcClients.Put(addr, client)
|
||||
affected := rpcClients.Put(addr, client)
|
||||
if !affected {
|
||||
defer func() {
|
||||
// 我尝试把自己这个client塞进map失败,说明已经有一个client塞进去了,那我自己用完了就关闭
|
||||
client.Close()
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,11 +116,6 @@ func rpcCall(addr string, items []*dataobj.MetricValue) (dataobj.TransferResp, e
|
|||
}
|
||||
}
|
||||
|
||||
if !affected {
|
||||
// 我尝试把自己这个client塞进map失败,说明已经有一个client塞进去了,那我自己用完了就关闭
|
||||
client.Close()
|
||||
}
|
||||
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue