Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
on Windows, breaking the main-push Windows check (PRs never caught it —
Windows CI is skipped on PRs). Now cfg-split: unix keeps the errno match,
Windows matches WSAEMFILE (10024) / WSAENOBUFS (10055) /
`ErrorKind::OutOfMemory`.
`ErrorKind::OutOfMemory`. Follow-up: the module's unit test
(`resource_exhaustion_classification`) also referenced `libc` errnos —
now cfg-split the same way (unix errnos vs WSA codes).

### Changed — AOF writer coalesces each group-commit batch into one write (PR #TBD)

Expand Down
17 changes: 15 additions & 2 deletions src/server/accept_backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,26 @@ mod tests {

#[test]
fn resource_exhaustion_classification() {
let emfile = std::io::Error::from_raw_os_error(libc::EMFILE);
let enfile = std::io::Error::from_raw_os_error(libc::ENFILE);
// Platform-native fd-exhaustion errnos: unix EMFILE/ENFILE,
// Windows WSAEMFILE/WSAENOBUFS (libc is not linked on Windows).
#[cfg(unix)]
let (emfile, enfile) = (
std::io::Error::from_raw_os_error(libc::EMFILE),
std::io::Error::from_raw_os_error(libc::ENFILE),
);
#[cfg(not(unix))]
let (emfile, enfile) = (
std::io::Error::from_raw_os_error(10024), // WSAEMFILE
std::io::Error::from_raw_os_error(10055), // WSAENOBUFS
);
assert!(is_resource_exhaustion(&emfile));
assert!(is_resource_exhaustion(&enfile));

// A reset-by-peer during accept is transient, not exhaustion.
#[cfg(unix)]
let aborted = std::io::Error::from_raw_os_error(libc::ECONNABORTED);
#[cfg(not(unix))]
let aborted = std::io::Error::from_raw_os_error(10053); // WSAECONNABORTED
assert!(!is_resource_exhaustion(&aborted));
// A non-OS error (e.g. synthesized) is not classified as exhaustion.
let other = std::io::Error::new(std::io::ErrorKind::Other, "synthetic");
Expand Down
Loading