Allow write guards to be disarmed before drop
- Ngôn ngữ chính
- Rust
- Star
- 26
- Fork
- 8
- Merge trung bình
- 16 giờ 41 phút
- Pull request đã merge (30 ngày)
- 15
Mô tả
## Problem
Shaq write guards publish their buffer when dropped. If a caller performs a fallible write directly into the buffer, an error can cause the guard to be dropped after only part of the value has been written. The incomplete or invalid buffer is then published to consumers.
For example:
```rust
wincode::serialize_into(guard.as_mut(), &event)?;
```
If serialization fails, error propagation drops the guard and publishes any bytes written before the failure.
## Proposed change
Add a method such as `disarm` or `abort` to write guards:
```rust
let mut guard = producer.write()?;
if let Err(err) = wincode::serialize_into(guard.as_mut(), &event) {
guard.disarm();
return Err(err);
}
```
Dropping an armed guard should preserve the existing publish-on-drop behavior. Dropping a disarmed guard should release or recycle the reserved slot without making its contents visible to consumers.
The change should be implemented for each write guard type in separate sub-issues.
## Acceptance criteria
- Write guards can be explicitly disarmed before they are dropped.
- Dropping an armed guard preserves the existing publish-on-drop behavior.
- Dropping a disarmed guard does not expose its buffer to consumers.
- The reserved slot is safely released or recycled for subsequent writes.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Start by locating each write guard type and its drop behavior, then trace the producer.write() path and how reserved slots are released or recycled. Check the existing producer/consumer behavior around publish-on-drop before deciding how each guard should handle disarming. Done means armed guards retain current publishing, while disarmed guards release the slot without exposing partial contents.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rust
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100