Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnet支持只设置SO_REUSEADDR防止服务端重启时因timewait而重启失败(addr in use) #266

Closed
liujiangang01 opened this issue Nov 4, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request proposal Proposal for this repo

Comments

@liujiangang01
Copy link

liujiangang01 commented Nov 4, 2021

背景:gnet目前支持ReusePort,目前gnet的实现上,该option除了设置SO_REUSEPORT 还设置了SO_REUSEADDR,但我们很多场景不想设置SO_REUSEPORT(该选项无法防御多实例一个网络地址启动,存在使用的局限性),我们只想设置SO_REUSEADDR,如这种场景:当重启server时,有一定概率重启失败,原因是server端主动关闭时,socket处于timewait状态,启动时无法绑定原来的地址(ip:port)导致

@liujiangang01 liujiangang01 added enhancement New feature or request proposal Proposal for this repo labels Nov 4, 2021
@liujiangang01 liujiangang01 changed the title gnet支持SO_REUSEADDR防止服务端重启时因timewait而重启失败(addr in use) gnet支持只设置SO_REUSEADDR防止服务端重启时因timewait而重启失败(addr in use) Nov 5, 2021
@panjf2000
Copy link
Owner

panjf2000 commented Nov 6, 2021

但我们很多场景不想设置SO_REUSEPORT(该选项无法防御多实例一个网络地址启动,存在使用的局限性)

不太理解你这句话里关于 SO_REUSEPORT 局限性的定论,能再说具体点吗?

@liujiangang01
Copy link
Author

liujiangang01 commented Nov 7, 2021 via email

@panjf2000
Copy link
Owner

你们是不想开启 SO_REUSEPORT 那种完全精确的相同的 IP+port 端口复用吧?

@panjf2000
Copy link
Owner

panjf2000 commented Nov 7, 2021

现在这两个属性的确是同时设置的,你们有时间可以提个 PR 修改一下。

This was referenced Nov 19, 2021
0-haha pushed a commit to 0-haha/gnet that referenced this issue Jan 25, 2023
Fixes panjf2000#266 
Fixes panjf2000#272 

Co-authored-by: zhongweikang <zhongweikang@sfmail.sf-express.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request proposal Proposal for this repo
Projects
None yet
Development

No branches or pull requests

2 participants