guowei-bian commented on issue #1380: URL: https://github.com/apache/incubator-brpc/issues/1380#issuecomment-822259545
感谢zyearn的回复,对我理解这块有很大帮助。下面是我的简单理解,请您空了帮忙看看是否有误,谢谢! 那么channel和socket是什么关系呢? 通常情况下,一个channel对应一个socket,随着channel的init创建socket,channel析构时销毁socket。但在多个channel使用single连接类型情况下,多个channel就公用一个socket;在这种情况下,某个channel析构后,socket也不会析构;所以,在两个channel并发delete后又new的工作场景下,其对应的socket是否能够真正释放后再重建就不能确定了。 前面在issue中提到的,在服务端重启后,两个客户端军返回E112,就是因为两个channel并发delete和new,一旦其中一个client delete和new执行完了,另一个client才执行,就会导致原socket不能释放,也就是新的client1和client2还继续使用原socket,而原socket由于服务端重启还处在恢复过程中,所以两个client给server发消息就报E112错误,直到socket通过healchcheck恢复才可以成功发送。 channel对socket的管理是通过引用计数实现的,只有socket的引用计数归0,socket才能回收。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
