MagicStack / MagicStack/uvloop
start_tls: AssertionError if writing is paused
还没有人认领这个 Issue。
- 主要语言
- Cython
- 星标
- 11.9k
- 派生
- 615
- PR 合并指标
- 30 天内没有已合并 PR
描述
First found in the CPython port of sslproto (see https://github.com/python/cpython/issues/109051 but disregard the title, it's not platform-specific), and it can be reproduced in uvloop.
Traceback
protocol.resume_writing() failed
protocol: <uvloop.loop.SSLProtocol object at 0x1033910c0>
transport: <TCPTransport closed=False reading=True 0x1098351c0>
Traceback (most recent call last):
File "uvloop/handles/basetransport.pyx", line 96, in uvloop.loop.UVBaseTransport._maybe_resume_protocol
run_in_context(
File "uvloop/loop.pyx", line 101, in uvloop.loop.run_in_context
return context.run(method)
File "uvloop/sslproto.pyx", line 922, in uvloop.loop.SSLProtocol.resume_writing
assert self._ssl_writing_paused
AssertionError
Simplest way to reproduce is to increase payload size in test_start_tls_server_1. Send will block and transport will request to pause writing. After start_tls(), the transport will attempt to resume the now-switched protocol, which was not aware it was ever supposed to be paused.
I commented further in the original bug with some notes. The CPython implementation is a bit different (it has a redundant buffering mechanism with a deque which I believe is unnecessary) but the fundamental issue is the same.
Question: what is the motivation for the extra flow control layer in SSLProtocol? It seems it was introduced in uvloop first. I suggested it can be removed and let the original protocol and original transport deal with flow control (which would also fix the bug). But it wouldn't be a good idea to remove it if it's solving a known problem.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 tests/test_tcp.py 开始,尤其是 test_start_tls_server_1,并复现 issue 中描述的大 payload 情况。然后检查 uvloop/sslproto.pyx 中 SSLProtocol.resume_writing 和 start_tls 附近的代码,以了解流控制的转换过程。完成的工作应包括一个已确认的 assertion 修复,以及一个覆盖 TLS 启动期间写入暂停情况的回归测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- networking
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100