Skip to content

Conversation

@mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Jul 8, 2025

User_events-based EventPipe sessions should end when the profiling process disconnects from the Diagnostic Port.

This PR does the following:

  • Adds the poll_func to IpcStream vtables
  • Adds ds_ipc_stream_poll based on ds_ipc_poll
  • Pass the continuation stream to user_events sessions
  • Extends the eventpipe streaming thread for user_events with ep_ipc_continuation_stream_connection_closed to detect disconnects.

Testing

Manual E2E testing with the same C program as #115265, except putting a getchar before closing the socket from the client side.

@mdh1418
Copy link
Member Author

mdh1418 commented Jul 8, 2025

cc: @pavelsavara for websocket poll implementation

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for detecting remote disconnections on user_events-based EventPipe sessions by extending IPC streams with polling capabilities and wiring up a continuation stream to session logic.

  • Introduce IpcStreamPollFunc in IPC vtables and implement ds_ipc_stream_poll variants
  • Define IpcContinuationStream and add ep_ipc_continuation_stream_connection_closed for hangup detection
  • Refactor session streaming thread to handle EP_SESSION_TYPE_USEREVENTS and unified ep_session_type_uses_streaming_thread predicate

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/native/eventpipe/ep-types-forward.h Forward-declare IpcContinuationStream
src/native/eventpipe/ep-stream.h Define IpcContinuationStream struct and closure API
src/native/eventpipe/ep-stream.c Add ep_ipc_stream_poll_vcall and continuation-stream check
src/native/eventpipe/ep-session.h Add continuation_stream field and streaming-thread predicate
src/native/eventpipe/ep-session.c Refactor streaming thread to support user events and cleanup
src/native/eventpipe/ep-ipc-stream.h Add IpcStreamPollFunc and ep_ipc_stream_poll_vcall prototype
src/native/eventpipe/ep-ipc-pal-types.h Define EventPipeIpcPollEvents enum and poll timeout constant
src/native/eventpipe/ds-ipc.c Replace DS_IPC_POLL_EVENTS_* with EP_IPC_POLL_EVENTS_*
src/native/eventpipe/ds-ipc-pal.h Declare ds_ipc_stream_poll
src/native/eventpipe/ds-ipc-pal-websocket.c Implement WebSocket poll func and update vtable
src/native/eventpipe/ds-ipc-pal-types.h Remove old DiagnosticsIpcPollEvents enum
src/native/eventpipe/ds-ipc-pal-socket.c Add socket poll func and vtable entry
src/native/eventpipe/ds-ipc-pal-namedpipe.c Stub out named pipe poll func
src/native/eventpipe/ds-eventpipe-protocol.c Always pass ds_ipc_stream_get_stream_ref(stream)

@mdh1418 mdh1418 force-pushed the ep_user_events_close_session_on_stream_close branch from a529a85 to c7fc5e6 Compare July 8, 2025 20:43
mdh1418 and others added 2 commits July 10, 2025 19:54
Revert moving IpcPollEvents to ep-ipc-pal-types header
Use IpcStream base type directly in sessions
Omit websocket ipc_stream_poll_func implementation
Change continuation stream poll timeout to infinite
Change returned PollEvent to none upon timeout
ep-stream.h for ep_ipc_stream_writer_alloc that was transitively
included by ep-file.h
ep-ipc-stream.h for ep_ipc_stream_poll_vcall
Remove prefix from IpcPollEvents enums and infinite timeout define
Expand connection closed detection to error case
Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mdh1418
Copy link
Member Author

mdh1418 commented Jul 15, 2025

/ba-g The remaining failure is a build timeout on android x64 which should be #117615

@mdh1418 mdh1418 merged commit 6a19342 into dotnet:main Jul 15, 2025
126 of 131 checks passed
@mdh1418 mdh1418 deleted the ep_user_events_close_session_on_stream_close branch July 15, 2025 15:33
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants