Skip to content

Commit

Permalink
[secure endpoint] backport fix from #37482 to 1.65.x (#37499)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdroth authored Aug 15, 2024
1 parent dcbbf06 commit cebe23b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/handshaker/security/secure_endpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ static void on_read(void* user_data, grpc_error_handle error) {

{
grpc_core::MutexLock l(&ep->read_mu);

// If we were shut down after this callback was scheduled with OK
// status but before it was invoked, we need to treat that as an error.
if (ep->wrapped_ep == nullptr && error.ok()) {
error = absl::CancelledError("secure endpoint shutdown");
}

uint8_t* cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
uint8_t* end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);

Expand Down Expand Up @@ -508,8 +515,10 @@ static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,

static void endpoint_destroy(grpc_endpoint* secure_ep) {
secure_endpoint* ep = reinterpret_cast<secure_endpoint*>(secure_ep);
ep->read_mu.Lock();
grpc_endpoint_destroy(ep->wrapped_ep);
ep->memory_owner.Reset();
ep->read_mu.Unlock();
SECURE_ENDPOINT_UNREF(ep, "destroy");
}

Expand Down

0 comments on commit cebe23b

Please sign in to comment.