From 61390a41fd6711c60bb4f4b15ca3706c4608555f Mon Sep 17 00:00:00 2001 From: Kannan J Date: Wed, 29 Jul 2026 13:50:16 +0000 Subject: [PATCH] xds: fix race condition in ext_proc client interceptor halfClose Fixes a race condition in ExternalProcessorClientInterceptor$DataPlaneClientCall.halfClose() that can cause the call to hang when the external processor stream completes concurrently. If the external processor stream completes (marking state as COMPLETED and setting passThroughMode to true) after halfClose() has already checked passThroughMode (seeing false), halfClose() would subsequently see the state as COMPLETED and return early without invoking proceedWithHalfClose(). This commit fixes the race by re-checking passThroughMode inside the isCompleted() block in halfClose(), ensuring we proceed with half-close if pass-through mode was enabled late. --- .../java/io/grpc/xds/ExternalProcessorClientInterceptor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java b/xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java index f61e1002926..2b56ed1b8ec 100644 --- a/xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java +++ b/xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java @@ -851,6 +851,11 @@ public void halfClose() { pendingHalfClose.set(true); if (extProcStreamState.get().isCompleted()) { + if (passThroughMode.get()) { + if (requestSideClosed.compareAndSet(false, true)) { + proceedWithHalfClose(); + } + } return; }