Skip to content

userspace socket: treat a closed peer handle as writable#43976

Open
pianiststickman wants to merge 9 commits intoenvoyproxy:mainfrom
pianiststickman:io-handle-write
Open

userspace socket: treat a closed peer handle as writable#43976
pianiststickman wants to merge 9 commits intoenvoyproxy:mainfrom
pianiststickman:io-handle-write

Conversation

@pianiststickman
Copy link
Contributor

@pianiststickman pianiststickman commented Mar 16, 2026

Commit Message: userspace socket: treat a closed peer handle as writable
Additional Description:
If one side of an internal listener connection closes, subsequent writes from the other side may result in data waiting to be flushed on a half-close. For connections managed by the HCM, this is covered by the delayed close timer, but TcpProxy does not implement a delayed close timer and therefore the connection leak in #38148 can persist.

The fix here is treat a closed peer handle as writable in order to get the connection to attempt a write and error out. (This is analogous to Linux signalling EPOLLOUT along with EPOLLHUP when a peer closes for reads; without it, an epoll consumer on the other side may continue to write-block a socket indefinitely, which is exactly what's happening here but in userspace.)
Risk Level: low; subsequent calls to write() are guarded against peer being nullptr, and the error when calling write() is the point.
Testing: new CI and integration test that reproduces the issue
Docs Changes: n/a
Release Notes: n/a
Fixes #38148

Signed-off-by: Eugene Chan <eugenechan@google.com>
@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43976 was opened by pianiststickman.

see: more, trace.

… descheduled.

Signed-off-by: Eugene Chan <eugenechan@google.com>
Signed-off-by: Eugene Chan <eugenechan@google.com>
Signed-off-by: Eugene Chan <eugenechan@google.com>
@pianiststickman pianiststickman changed the title userspace socket: trigger Write event when peer handle is closed userspace socket: treat a closed peer handle as writable Mar 17, 2026
Signed-off-by: Eugene Chan <eugenechan@google.com>
Signed-off-by: Eugene Chan <eugenechan@google.com>
Signed-off-by: Eugene Chan <eugenechan@google.com>
Signed-off-by: Eugene Chan <eugenechan@google.com>
…ndle-write

Signed-off-by: Eugene Chan <eugenechan@google.com>
@pianiststickman pianiststickman marked this pull request as ready for review March 19, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Envoy internal listener's active connections are not released with TcpProxy case

1 participant