Skip to content

Commit

Permalink
core: fix drainPendingCalls might be called twice
Browse files Browse the repository at this point in the history
Fixing the bug: if two consecutive name resolution updates are queued together in SynchronizationContext, drainPendingCalls() might be called twice and be broken.
  • Loading branch information
dapengzhang0 committed Sep 10, 2020
1 parent 49e47a4 commit 73dd367
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
Expand Up @@ -1568,6 +1568,7 @@ public void run() {
Status serviceConfigError = configOrError != null ? configOrError.getError() : null;

ManagedChannelServiceConfig effectiveServiceConfig;
InternalConfigSelector prevConfigSelector = configSelector.get();
if (!lookUpServiceConfig) {
if (validServiceConfig != null) {
channelLogger.log(
Expand Down Expand Up @@ -1639,7 +1640,9 @@ public void run() {
re);
}
}
realChannel.drainPendingCalls();
if (prevConfigSelector == INITIAL_PENDING_SELECTOR) {
realChannel.drainPendingCalls();
}

Attributes effectiveAttrs = resolutionResult.getAttributes();
// Call LB only if it's not shutdown. If LB is shutdown, lbHelper won't match.
Expand Down

0 comments on commit 73dd367

Please sign in to comment.