From 4f91cbd96fb225fa3797c819150cc51679cb34b4 Mon Sep 17 00:00:00 2001 From: Tin Dang Date: Wed, 8 Jul 2026 02:52:15 +0700 Subject: [PATCH] fix(server): cfg-gate accept-backoff TEST libc errnos for Windows Follow-up to the accept_backoff Windows fix in PR #242: the module's resource_exhaustion_classification unit test also referenced libc::EMFILE/ENFILE/ECONNABORTED, so the main-push Windows check kept failing E0433 on the test build. cfg-split the test the same way as the function under test: unix keeps the libc errnos, Windows uses WSAEMFILE (10024) / WSAENOBUFS (10055) / WSAECONNABORTED (10053). The Windows job runs only on main pushes (skipped on PRs), which is why neither the original break (PR #230) nor the partial fix could be validated pre-merge. author: Tin Dang --- CHANGELOG.md | 4 +++- src/server/accept_backoff.rs | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea9ee5f45..632594204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/server/accept_backoff.rs b/src/server/accept_backoff.rs index 06da10087..fa042b812 100644 --- a/src/server/accept_backoff.rs +++ b/src/server/accept_backoff.rs @@ -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");