/** * Checks time of active handshake procedures and restarts them if time is up {@link UDPAdapter#HANDSHAKE_TIMEOUT_MILLIS} * @param s session * @param now pass here Instant.now() */ private void restartHandshakeIfNeeded(Session s, Instant now) { if (s.state.get() == Session.STATE_HANDSHAKE) { if (s.handshakeExpiresAt.isBefore(now)) { report(logLabel, ()->"handshaking with nodeId="+s.remoteNodeInfo.getNumber()+" is timed out, restart", VerboseLevel.BASE); s.handshakeStep.set(Session.HANDSHAKE_STEP_WAIT_FOR_WELCOME); s.handshakeExpiresAt = now.plusMillis(HANDSHAKE_TIMEOUT_MILLIS); sendHello(s); } } }