Skip to content

Commit 6c4220a

Browse files
committed
ZOOKEEPER-3188: fix SendWorker.asyncValidateIfSocketIsStillReachable
1 parent 5b22432 commit 6c4220a

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,29 +1263,22 @@ public void run() {
12631263

12641264
public void asyncValidateIfSocketIsStillReachable() {
12651265
if(ongoingAsyncValidation.compareAndSet(false, true)) {
1266-
Thread validator = new Thread(() -> {
1266+
new Thread(() -> {
12671267
LOG.debug("validate if destination address is reachable for sid {}", sid);
12681268
if(sock != null) {
12691269
InetAddress address = sock.getInetAddress();
12701270
try {
12711271
if (address.isReachable(500)) {
12721272
LOG.debug("destination address {} is reachable for sid {}", address.toString(), sid);
1273+
ongoingAsyncValidation.set(false);
12731274
return;
12741275
}
12751276
} catch (NullPointerException | IOException ignored) {
12761277
}
12771278
LOG.warn("destination address {} not reachable anymore, shutting down the SendWorker for sid {}", address.toString(), sid);
12781279
this.finish();
12791280
}
1280-
});
1281-
validator.start();
1282-
try {
1283-
validator.join();
1284-
} catch (InterruptedException ignored) {
1285-
// we don't care if the validation was interrupted. If SenderWorker is not working, we will
1286-
// try to connect and re-validate later
1287-
}
1288-
ongoingAsyncValidation.set(false);
1281+
}).start();
12891282
} else {
12901283
LOG.debug("validation of destination address for sid {} is skipped (it is already running)", sid);
12911284
}

0 commit comments

Comments
 (0)