unix: Return ECONNRESET when listener is closed with pending connections#12594
Merged
copybara-service[bot] merged 2 commits intomasterfrom Feb 6, 2026
Merged
unix: Return ECONNRESET when listener is closed with pending connections#12594copybara-service[bot] merged 2 commits intomasterfrom
copybara-service[bot] merged 2 commits intomasterfrom
Conversation
When a Unix stream socket listener is closed while there are pending (connected but not accepted) connections, gVisor was returning EOF (0) on read() instead of ECONNRESET error, and epoll was not reporting EPOLLERR. This differs from Linux kernel behavior. This change: 1. Sets SO_ERROR to ECONNRESET on client endpoints when listener closes pending connections 2. Notifies waiter queue with EventErr so epoll reports EPOLLERR 3. Makes read() return ECONNRESET on first call, then EOF on subsequent calls (matching Linux's read-once-and-clear semantics) 4. Adds Readiness check for EventErr based on lastError state 5. Adds UpdateLastError to baseEndpoint to support SetLastError This fixes compatibility issues with async frameworks like tokio that rely on these semantics to detect connection failures. Fixes #12576 Signed-off-by: Tan Yifeng <yiftan@tencent.com>
51ee5ea to
cde905b
Compare
PiperOrigin-RevId: 866634080
cde905b to
3967795
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
unix: Return ECONNRESET when listener is closed with pending connections
When a Unix stream socket listener is closed while there are pending (connected but not accepted) connections, gVisor was returning EOF (0) on read() instead of ECONNRESET error, and epoll was not reporting EPOLLERR. This differs from Linux kernel behavior.
This change:
This fixes compatibility issues with async frameworks like tokio that rely on these semantics to detect connection failures.
Fixes #12576
FUTURE_COPYBARA_INTEGRATE_REVIEW=#12577 from tanyifeng:fix-return-rst 20366fd