core: fix drainPendingCalls might be called twice

Fixing the bug: if two consecutive name resolution updates are queued together in SynchronizationContext, drainPendingCalls() might be called twice and be broken.
This commit is contained in:
ZHANG Dapeng 2020-09-10 15:11:19 -07:00 committed by GitHub
parent 49e47a4089
commit 73dd3672fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -1568,6 +1568,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
Status serviceConfigError = configOrError != null ? configOrError.getError() : null;
ManagedChannelServiceConfig effectiveServiceConfig;
InternalConfigSelector prevConfigSelector = configSelector.get();
if (!lookUpServiceConfig) {
if (validServiceConfig != null) {
channelLogger.log(
@ -1639,7 +1640,9 @@ final class ManagedChannelImpl extends ManagedChannel implements
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.