Skip to content

Commit 61390a4

Browse files
committed
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.
1 parent 21d6c71 commit 61390a4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎xds/src/main/java/io/grpc/xds/ExternalProcessorClientInterceptor.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,11 @@ public void halfClose() {
851851
pendingHalfClose.set(true);
852852

853853
if (extProcStreamState.get().isCompleted()) {
854+
if (passThroughMode.get()) {
855+
if (requestSideClosed.compareAndSet(false, true)) {
856+
proceedWithHalfClose();
857+
}
858+
}
854859
return;
855860
}
856861

0 commit comments

Comments
 (0)