Fix semaphore usage error when calculating address. (#7850)

* fix addr cache bug

* fix router chain loop err
This commit is contained in:
panxiaojun233 2021-05-24 11:54:12 +08:00 committed by GitHub
parent 3a8f44eb38
commit 845003f500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -267,11 +267,11 @@ public class RouterChain<T> {
}
if (notify) {
if (loopPermitNotify.tryAcquire()) {
loopPool.submit(new NotifyLoopRunnable(true));
loopPool.submit(new NotifyLoopRunnable(true, loopPermitNotify));
}
} else {
if (loopPermit.tryAcquire()) {
loopPool.submit(new NotifyLoopRunnable(false));
loopPool.submit(new NotifyLoopRunnable(false, loopPermit));
}
}
}
@ -279,14 +279,16 @@ public class RouterChain<T> {
class NotifyLoopRunnable implements Runnable {
private final boolean notify;
private final Semaphore loopPermit;
public NotifyLoopRunnable(boolean notify) {
public NotifyLoopRunnable(boolean notify, Semaphore loopPermit) {
this.notify = notify;
this.loopPermit = loopPermit;
}
@Override
public void run() {
loopPermitNotify.release();
loopPermit.release();
buildCache(notify);
}
}