Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EventEngine] Update contract for Listener's on_shutdown execution #33003

Conversation

drfloob
Copy link
Member

@drfloob drfloob commented May 3, 2023

See event_engine.h for the contract change. All other changes are cleanup.

I confirmed that both the Posix and Windows implementations comply with this already.

On Windows, the WindowsEventEngineListener will only call on_shutdown after all SinglePortSocketListeners have been destroyed, which ensures that no on_accept callback will be executed, even if there is still trailing overlapped activity on the listening socket.

On Posix, the PosixEngineListenerImpl will only call on_shutdown after all AsyncConnectionAcceptors have been destroyed, which ensures EventHandle::OrphanHandle has been called. The OrphanHandle contract indicates that all existing notify closures must have already run. The implementation looks to comply, so if it does not, that's a bug.

// operations cannot be performed on the handle. In general, this method
// should only be called after ShutdownHandle and after all existing NotifyXXX
// closures have run and there is no waiting NotifyXXX closure.

@drfloob drfloob added release notes: yes Indicates if PR needs to be in release notes and removed lang/core labels May 3, 2023
@drfloob drfloob merged commit 18c1cc5 into grpc:master May 3, 2023
58 of 64 checks passed
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label May 3, 2023
paulosjca pushed a commit to paulosjca/grpc that referenced this pull request May 4, 2023
…rpc#33003)

See `event_engine.h` for the contract change. All other changes are
cleanup.

I confirmed that both the Posix and Windows implementations comply with
this already.

On Windows, the `WindowsEventEngineListener` will only call
`on_shutdown` after all `SinglePortSocketListener`s have been destroyed,
which ensures that no `on_accept` callback will be executed, even if
there is still trailing overlapped activity on the listening socket.

On Posix, the `PosixEngineListenerImpl` will only call `on_shutdown`
after all `AsyncConnectionAcceptor`s have been destroyed, which ensures
`EventHandle::OrphanHandle` has been called. The `OrphanHandle` contract
indicates that all existing notify closures must have already run. The
implementation looks to comply, so if it does not, that's a bug.
https://github.com/grpc/grpc/blob/3aae08d25e69af36445de7618072d708d839642d/src/core/lib/event_engine/posix_engine/event_poller.h#L48-L50
wanlin31 pushed a commit that referenced this pull request May 18, 2023
…33003)

See `event_engine.h` for the contract change. All other changes are
cleanup.

I confirmed that both the Posix and Windows implementations comply with
this already.

On Windows, the `WindowsEventEngineListener` will only call
`on_shutdown` after all `SinglePortSocketListener`s have been destroyed,
which ensures that no `on_accept` callback will be executed, even if
there is still trailing overlapped activity on the listening socket.

On Posix, the `PosixEngineListenerImpl` will only call `on_shutdown`
after all `AsyncConnectionAcceptor`s have been destroyed, which ensures
`EventHandle::OrphanHandle` has been called. The `OrphanHandle` contract
indicates that all existing notify closures must have already run. The
implementation looks to comply, so if it does not, that's a bug.
https://github.com/grpc/grpc/blob/3aae08d25e69af36445de7618072d708d839642d/src/core/lib/event_engine/posix_engine/event_poller.h#L48-L50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloat/none imported Specifies if the PR has been imported to the internal repository lang/core per-call-memory/neutral per-channel-memory/neutral release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants