diff --git a/src/core/lib/event_engine/posix.h b/src/core/lib/event_engine/posix.h index 9594625d84f..7c46a8943b8 100644 --- a/src/core/lib/event_engine/posix.h +++ b/src/core/lib/event_engine/posix.h @@ -37,6 +37,10 @@ class PosixEndpointWithFdSupport : public EventEngine::Endpoint { /// Returns the file descriptor associated with the posix endpoint. virtual int GetWrappedFd() = 0; + /// Returns if the Endpoint supports tracking events from errmsg queues on + /// posix systems. + virtual bool CanTrackErrors() = 0; + /// Shutdown the endpoint. This function call should trigger execution of /// any pending endpoint Read/Write callbacks with appropriate error /// absl::Status. After this function call any subsequent endpoint diff --git a/src/core/lib/event_engine/posix_engine/posix_endpoint.h b/src/core/lib/event_engine/posix_engine/posix_endpoint.h index b7eabf91644..8c2fae5ecf5 100644 --- a/src/core/lib/event_engine/posix_engine/posix_endpoint.h +++ b/src/core/lib/event_engine/posix_engine/posix_endpoint.h @@ -493,6 +493,8 @@ class PosixEndpointImpl : public grpc_core::RefCounted { int GetWrappedFd() { return fd_; } + bool CanTrackErrors() const { return poller_->CanTrackErrors(); } + void MaybeShutdown( absl::Status why, absl::AnyInvocable release_fd)> on_release_fd); @@ -635,6 +637,8 @@ class PosixEndpoint : public PosixEndpointWithFdSupport { int GetWrappedFd() override { return impl_->GetWrappedFd(); } + bool CanTrackErrors() override { return impl_->CanTrackErrors(); } + void Shutdown(absl::AnyInvocable release_fd)> on_release_fd) override { if (!shutdown_.exchange(true, std::memory_order_acq_rel)) { @@ -691,6 +695,11 @@ class PosixEndpoint : public PosixEndpointWithFdSupport { "PosixEndpoint::GetWrappedFd not supported on this platform"); } + bool CanTrackErrors() override { + grpc_core::Crash( + "PosixEndpoint::CanTrackErrors not supported on this platform"); + } + void Shutdown(absl::AnyInvocable release_fd)> on_release_fd) override { grpc_core::Crash("PosixEndpoint::Shutdown not supported on this platform"); diff --git a/src/core/lib/iomgr/event_engine_shims/endpoint.cc b/src/core/lib/iomgr/event_engine_shims/endpoint.cc index 7e93d30d7aa..ae9004f11b6 100644 --- a/src/core/lib/iomgr/event_engine_shims/endpoint.cc +++ b/src/core/lib/iomgr/event_engine_shims/endpoint.cc @@ -256,6 +256,15 @@ class EventEngineEndpointWrapper { } } + bool CanTrackErrors() { + if (EventEngineSupportsFd()) { + return reinterpret_cast(endpoint_.get()) + ->CanTrackErrors(); + } else { + return false; + } + } + private: void OnShutdownInternal() { { @@ -378,7 +387,12 @@ int EndpointGetFd(grpc_endpoint* ep) { return eeep->wrapper->Fd(); } -bool EndpointCanTrackErr(grpc_endpoint* /* ep */) { return false; } +bool EndpointCanTrackErr(grpc_endpoint* ep) { + auto* eeep = + reinterpret_cast( + ep); + return eeep->wrapper->CanTrackErrors(); +} grpc_endpoint_vtable grpc_event_engine_endpoint_vtable = { EndpointRead,