docs(plan): 添加 Windows 兼容性详细技术方案

- 描述目标:在 Windows 上编译运行 cocoon
- 分析核心发现:coco 库已有 Windows 支持,问题在 cocoon 的 POSIX 依赖
- 提出方案:引入 platform.h + platform.c 平台抽象层
- 列出关键 API 映射:POSIX → Windows 对照表
- 记录零拷贝策略:Windows 暂时回退到 read+send,后续用 TransmitFile 优化
- 指定执行方式:Subagent-Driven 逐个 Task 实现
This commit is contained in:
xfy 2026-06-04 08:16:27 +08:00
parent 0fd5ebc043
commit ca7b33aa10

View File

@ -63,6 +63,24 @@
4. **[中] server.c 单元测试** — 需要 mock socket 和 coco 协程环境
5. **[中] 完善 Doxygen 中文注释** — 所有模块的公共 API 需要完整文档
### Windows 兼容性详细计划
**目标**:在 Windows 上编译运行 cocoon目前仅支持 Linux/macOS
**核心发现**coco 库**已有完整 Windows 支持**`poll_windows.c` 使用 WSAPoll`coco_read/coco_write/coco_accept` 内部调用 `recv/send/accept`)。问题在 cocoon 自身直接调用大量 POSIX API。
**方案**:引入 `platform.h` + `platform.c` 平台抽象层,封装所有 POSIX/Windows 差异。
| 变更 | 说明 |
|------|------|
| **新增** | `src/platform.h`, `src/platform.c`, `CMakeLists.txt` |
| **修改** | `server.c`, `static.c`, `main.c`, `server.h`, `Makefile` |
| **移除依赖** | `sys/socket.h`, `sendfile.h`, `dirent.h`, `signal.h`, `unistd.h` |
| **关键映射** | `close()``closesocket()`, `fcntl()``ioctlsocket()`, `sendfile()``read+send` 循环, `opendir()``FindFirstFileA()` |
| **零拷贝** | Windows 上暂时移除 sendfile后续可用 TransmitFile 优化) |
**执行方式**Option 1 — Subagent-Driven子代理逐个 Task 实现,每步自动 review
## 最近行动记录
- 2026-06-04: **本轮行动 — Brotli 压缩支持**