Skip to content

Commit

Permalink
ZOOKEEPER-3188: fix SendWorker.asyncValidateIfSocketIsStillReachable
Browse files Browse the repository at this point in the history
  • Loading branch information
symat committed Aug 12, 2019
1 parent 5b22432 commit 6c4220a
Showing 1 changed file with 3 additions and 10 deletions.
Expand Up @@ -1263,29 +1263,22 @@ public void run() {

public void asyncValidateIfSocketIsStillReachable() {
if(ongoingAsyncValidation.compareAndSet(false, true)) {
Thread validator = new Thread(() -> {
new Thread(() -> {
LOG.debug("validate if destination address is reachable for sid {}", sid);
if(sock != null) {
InetAddress address = sock.getInetAddress();
try {
if (address.isReachable(500)) {
LOG.debug("destination address {} is reachable for sid {}", address.toString(), sid);
ongoingAsyncValidation.set(false);
return;
}
} catch (NullPointerException | IOException ignored) {
}
LOG.warn("destination address {} not reachable anymore, shutting down the SendWorker for sid {}", address.toString(), sid);
this.finish();
}
});
validator.start();
try {
validator.join();
} catch (InterruptedException ignored) {
// we don't care if the validation was interrupted. If SenderWorker is not working, we will
// try to connect and re-validate later
}
ongoingAsyncValidation.set(false);
}).start();
} else {
LOG.debug("validation of destination address for sid {} is skipped (it is already running)", sid);
}
Expand Down

0 comments on commit 6c4220a

Please sign in to comment.