mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Maximize priority of the cached address on successful connection
This commit is contained in:
18
src/net.rs
18
src/net.rs
@@ -58,7 +58,12 @@ async fn lookup_host_with_cache(
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT (hostname, port, address)
|
||||
DO UPDATE SET timestamp=excluded.timestamp",
|
||||
paramsv![hostname, port, addr.to_string(), now.saturating_add(i)],
|
||||
paramsv![
|
||||
hostname,
|
||||
port,
|
||||
addr.to_string(),
|
||||
now.saturating_add(i).saturating_add(1)
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
@@ -125,6 +130,17 @@ pub(crate) async fn connect_tcp(
|
||||
match connect_tcp_inner(resolved_addr, timeout_val).await {
|
||||
Ok(stream) => {
|
||||
tcp_stream = Some(stream);
|
||||
|
||||
// Maximize priority of this cached entry.
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"UPDATE dns_cache
|
||||
SET timestamp = ?
|
||||
WHERE address = ?",
|
||||
paramsv![time(), resolved_addr.to_string()],
|
||||
)
|
||||
.await?;
|
||||
break;
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
Reference in New Issue
Block a user