diff --git a/.cocoon-plan.md b/.cocoon-plan.md index 60e8ee8..de8b257 100644 --- a/.cocoon-plan.md +++ b/.cocoon-plan.md @@ -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 压缩支持**