From c9a751d9d73debb53c1d2f8b81808ca874e76836 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Wed, 31 Jul 2024 09:06:25 -0700 Subject: [PATCH] fix error handling in CFWriteStreamWrite --- .../lib/event_engine/cf_engine/cfstream_endpoint.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc index 47e67d8e4a4..4721437860b 100644 --- a/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +++ b/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc @@ -335,9 +335,18 @@ void CFStreamEndpointImpl::DoWrite( continue; } - size_t written_size = + CFIndex written_size = CFWriteStreamWrite(cf_write_stream_, slice.begin(), slice.size()); + if (written_size < 0) { + auto status = CFErrorToStatus(CFWriteStreamCopyError(cf_write_stream_)); + GRPC_TRACE_LOG(event_engine_endpoint, INFO) + << "CFStream write error: " << status + << ", written_size: " << written_size; + on_writable(status); + return; + } + total_written_size += written_size; if (written_size < slice.size()) { SliceBuffer written;