Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
fix: use origin expireNanoTime to init new clientRequestRound (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
foreverneverer authored May 13, 2020
1 parent 76620ab commit 197c7ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,28 @@ public ClientRequestRound(
Table.ClientOPCallback cb,
boolean enableCounter,
long timeoutInMilliseconds) {
operator = op;
callback = cb;
timeoutMs = timeoutInMilliseconds;
this(
op,
cb,
enableCounter,
System.nanoTime() + timeoutInMilliseconds * 1000000L,
timeoutInMilliseconds);
}

public ClientRequestRound(
client_operator op,
Table.ClientOPCallback cb,
boolean enableCounter,
long expireNanoTime,
long timeoutInMilliseconds) {
this.operator = op;
this.callback = cb;
this.timeoutMs = timeoutInMilliseconds;

this.enableCounter = enableCounter;
createNanoTime = System.nanoTime();
expireNanoTime = createNanoTime + timeoutMs * 1000000L;
isCompleted = false;
backupRequestTask = null;
this.expireNanoTime = expireNanoTime;
this.isCompleted = false;
this.backupRequestTask = null;
}

public com.xiaomi.infra.pegasus.operator.client_operator getOperator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,16 @@ void onRpcReply(
}

// must use new round here, because round.isSuccess is true now
tryDelayCall(
// must use round.expireNanoTime to init, otherwise "round.expireNanoTime - System.nanoTime() >
// nanoDelay" in "tryDelayCall()" will be always true
ClientRequestRound delayRequestRound =
new ClientRequestRound(
round.operator, round.callback, round.enableCounter, round.timeoutMs),
tryId + 1);
round.operator,
round.callback,
round.enableCounter,
round.expireNanoTime,
round.timeoutMs);
tryDelayCall(delayRequestRound, tryId + 1);
}

void tryDelayCall(final ClientRequestRound round, final int tryId) {
Expand Down

0 comments on commit 197c7ee

Please sign in to comment.