weibocom / motan

A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.
Other
5.88k stars 1.78k forks source link

Netty4Server start时存在bug #319

Open MrHongCN opened 7 years ago

MrHongCN commented 7 years ago

在 com.weibo.api.motan.transport.netty4.server.Netty4Server 中 第82 行中 不应该sleep 而应该依据 state判断 try { Thread.sleep(1000); } catch (InterruptedException e) { LoggerUtil.error("NettyServer open interrupted: url=" + url.getUri(), e); }

rayzhang0603 commented 7 years ago

这里的sleep是因为channel的open是异步进行的,server端channel的open依赖channelFuture的sync()方法(line 69),如果超过1s没有bind成功,此时state是uninit状态,这种情况也会算作bind失败。 这里可以优化一下使其更加易读一些。

MrHongCN commented 7 years ago

1s 不太合适吧 运行慢一点 可能就直接bind 失败了 不是所有情况下都可以1s 启动好的

rayzhang0603 commented 7 years ago

嗯,这里的实现确实有待改进,可以根据connectTimeout配置来进行判断。最近很快会对netty4分支进行优化开发,到时会改进这个问题,感谢反馈!