sofastack / sofa-bolt

SOFABolt is a lightweight, easy to use and high performance remoting framework based on Netty.
https://www.sofastack.tech/projects/sofa-bolt/
Apache License 2.0
2.44k stars 860 forks source link

AbstractConnectionFactory新建链接 #277

Open vinsonJiang opened 2 years ago

vinsonJiang commented 2 years ago

Your question

多线程创建连接

Your scenes

Bootstrap是单例,AbstractConnectionFactory调用doCreateConnection创建连接,设置connectTimeout参数,不会出现线程问题吗?

nobodyiam commented 2 years ago

@chuailiwu would you please help to take a look?

chuailiwu commented 2 years ago

Your question

多线程创建连接

Your scenes

Bootstrap是单例,AbstractConnectionFactory调用doCreateConnection创建连接,设置connectTimeout参数,不会出现线程问题吗?

好问题,调试确认了一下,结论如下: 确实可能会有你说的多个线程并发设置时,这个超时时间可能会混的问题。options为Bootstrap的属性,创建channel 时会公用这个options。 解法:需要在外面加一个锁来解决。