Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

WEBrick::HTTPProxyServer hangs when process exits

未关闭
#97 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
ruby

调研方向

从 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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/webrick 的其他 Issue

查看 ruby/webrick 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。