start with optimistic profile if received from hostcache or a new successful connection has been made

pull/53/head
Zlatin Balevsky 2020-10-21 05:46:32 +01:00
parent 768673e979
commit 38bf4f2ea2
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 8 additions and 2 deletions

View File

@ -42,9 +42,10 @@ class H2HostCache extends HostCache {
protected synchronized void hostDiscovered(Destination d, boolean fromHostcache) {
// overwrite MC with optimistic values
if (fromHostcache) {
sql.execute("delete from HOST_ATTEMPTS where DESTINATION='${d.toBase64()}';")
sql.execute("delete from HOST_ATTEMPTS where DESTINATION=${d.toBase64()}")
profiles.put(d, new HostMCProfile())
} else if (uniqueHosts.add(d)) {
}
if (uniqueHosts.add(d)) {
allHosts.add(d)
profiles.put(d, new HostMCProfile())
}
@ -55,6 +56,11 @@ class H2HostCache extends HostCache {
log.fine("onConnection ${d.toBase32()} status $status")
if (status == ConnectionAttemptStatus.SUCCESSFUL && uniqueHosts.add(d)) {
allHosts.add(d)
profiles.put(d, new HostMCProfile())
}
// record into db
def timestamp = new Date(System.currentTimeMillis())
timestamp = SDF.format(timestamp)