WEBrick::HTTPProxyServer hangs when process exits
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- ruby
- 领域
- backend, networking
调研方向
从 WEBrick::HTTPProxyServer#do_CONNECT 及其 shutdown 路径开始,然后检查所引用的 ext/socket/ipsocket.c 清理代码。重现多线程代理退出的过程,并追踪是 CONNECT socket 还是 thread join 导致了挂起。完成的标准是解释清楚 shutdown 行为和 nil socket 路径,并通过回归测试覆盖它们。
由索引模型根据 Issue 内容生成。
描述
I have a proxy server running in a thread:
@server = WEBrick::HTTPProxyServer.new(ServerType: Thread, BindAddress: host, Port: port)
when process exists I call @server.shutdown but it hangs forever so that I have to send Ctrl+C. While debugging this issue I figured that def do_CONNECT(req, res) which binds a socket os = TCPSocket.new(host, port) sometimes in ensure block has os set to nil. Which leads me to a question if https://github.com/ruby/ruby/blob/55c771c302f94f1d1d95bf41b42459b4d2d1c337/ext/socket/ipsocket.c#L187 socket can be nil if we take into account inetsock_cleanup(VALUE v) which returns return Qnil;
I fixed the issue by adding raise HTTPStatus::EOFError unless os in ensure block so that we don't interact with the rest of descriptors. Other note is that none of the rescue blocks were called in do_CONNECT.
Update: I still assume that TCPSocket.new returns a socket or raises an error, but in my case I have no idea how I end up with nil as a socket even though we call thgroup.list.each{|th| th.join if th[:WEBrickThread] } in shutdown. Maybe because ruby starts to terminate all threads because main thread exits?
- 主要语言
- Ruby
- 星标
- 327
- 派生
- 113
- 平均合并
- 4 小时 2 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/webrick 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 45/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
TheOdinProject/curriculum#31417 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 65/100
glossarist/glossarist-ruby#238 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
palladius/rails8-app-on-gcp#145 ·