Skip to content

Commit adf01bf

Browse files
xds: fix race condition in ext_proc client interceptor halfClose (#12948)
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 296c007 commit adf01bf

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
@@ -860,6 +860,11 @@ public void halfClose() {
860860
pendingHalfClose.set(true);
861861

862862
if (extProcStreamState.get().isCompleted()) {
863+
if (passThroughMode.get()) {
864+
if (requestSideClosed.compareAndSet(false, true)) {
865+
proceedWithHalfClose();
866+
}
867+
}
863868
return;
864869
}
865870

0 commit comments

Comments
 (0)