ipc (Windows): a server shutdown discards bytes the client has not read (hostd raw terminals may lose the last output)

Đang mở
#529 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
69/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend, networking

Hướng nghiên cứu

Start in the Windows implementation of atlas_core::ipc's Stream::Server::poll_shutdown and inspect how it calls NamedPipeServer::disconnect(). Check the Win32 pipe shutdown behavior and add a bounded wait for the client to read the pending bytes or close. Add a cfg(windows) IPC test where a slow client reads all N bytes before EOF; verify it passes, including the existing broken-pipe EOF handling.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: runtime type: bug

What

On Windows, atlas_core::ipc's server end discards data the client has not read yet when it shuts down. Stream::Server::poll_shutdown calls NamedPipeServer::disconnect() (DisconnectNamedPipe), and per the Win32 docs that discards anything still in the pipe buffer unless the server first waits for the client (FlushFileBuffers) or for it to close.

Found while fixing the Windows askpass in #525, where it made the password never arrive (3 tests failed on windows-latest: the helper read nothing).

Where else it can bite

crates/atlas-host/src/server.rs, raw terminal connections (attach_raw loop, around L1470-1483 on main at time of writing): when the PTY ends (rrx closes) the loop breaks and calls w.shutdown().await right after the last write_all. On Windows the last chunk of terminal output before the process exits can be lost for a client that has not read it yet. Not reproduced; found by reading the code.

To check: crates/atlas-desktop/src/ctl.rs:123 and debug.rs:145 write a reply and drop the stream (no explicit shutdown). Whether CloseHandle alone loses unread data was not verified.

Proposed fix

Make the semantics safe in one place instead of at each call site: on Windows, poll_shutdown of a server stream waits until the client has read what was written (or has closed) before disconnecting, with a bound. Test under cfg(windows) in ipc tests: server writes N bytes then shuts down; a slow client still reads all N bytes, then EOF. #525 already maps ERROR_BROKEN_PIPE/ERROR_PIPE_NOT_CONNECTED to EOF on the sync client.

Ngôn ngữ chính
Rust
Star
3
Fork
1
Merge trung bình
9 giờ 51 phút
Pull request đã merge (30 ngày)
310

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codeatlasdev/atlas

Tất cả issue của codeatlasdev/atlas

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.