Skip to content

Commit

Permalink
Move cancelling rpcRetryTimer from readyHandler to `startRpcStrea…
Browse files Browse the repository at this point in the history
…m`. Remove some unnecessary checks from RpcRetryTask.
  • Loading branch information
larry-safran committed Nov 23, 2024
1 parent f352d33 commit f355bdf
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions xds/src/main/java/io/grpc/xds/client/ControlPlaneClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ boolean isInError() {
*/
// Must be synchronized.
void readyHandler(boolean shouldSendInitialRequest) {
if (rpcRetryTimer != null) {
rpcRetryTimer.cancel();
rpcRetryTimer = null;
}

if (shouldSendInitialRequest) {
xdsResponseHandler.handleStreamRestarted(serverInfo);
}
Expand All @@ -242,6 +237,12 @@ void readyHandler(boolean shouldSendInitialRequest) {
// Must be synchronized.
private void startRpcStream() {
checkState(adsStream == null, "Previous adsStream has not been cleared yet");

if (rpcRetryTimer != null) {
rpcRetryTimer.cancel();
rpcRetryTimer = null;
}

adsStream = new AdsStream();
adsStream.start();
logger.log(XdsLogLevel.INFO, "ADS stream started");
Expand Down Expand Up @@ -274,13 +275,11 @@ public final class RpcRetryTask implements Runnable {
@Override
public void run() {
logger.log(XdsLogLevel.DEBUG, "Retry timeout. Restart ADS stream {0}", logId);
if (shutdown || isReady()) {
if (shutdown) {
return;
}

if (adsStream == null) {
startRpcStream();
}
startRpcStream();

// handling CPC management is triggered in readyHandler
}
Expand Down

0 comments on commit f355bdf

Please sign in to comment.