smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.08k stars 1.16k forks source link

为什么error处理中没有关闭tcp? #799

Closed namewxt1220 closed 1 year ago

namewxt1220 commented 1 year ago

https://github.com/smallnest/rpcx/blob/85b290c311aef305435d1bade0abeeab7cf5c24f/client/client.go#L570-L595 我看到connection write后,会返回error,为什么处理这个error时没有close掉tcp?是有什么特别的用意吗?

smallnest commented 1 year ago

应该close

smallnest commented 1 year ago

xclient 会 close它

func (c *xClient) removeClient(k, servicePath, serviceMethod string, client RPCClient) {
    c.mu.Lock()
    cl := c.findCachedClient(k, servicePath, serviceMethod)
    if cl == client {
        c.deleteCachedClient(client, k, servicePath, serviceMethod)
    }
    c.mu.Unlock()

    if client != nil {
        client.UnregisterServerMessageChan()
        client.Close()
    }
}