refactor: remove forward_with_failover duplication, fix warm-branch hedge bug

- Remove forward_with_failover (parsed): warm_domain now uses _raw + insert_wire
- forward_udp delegates to forward_udp_raw (single UDP socket implementation)
- forward_query uses unified _raw path for all protocols
- Fix send_query_hedged warm branch: bare select! dropped secondary on primary
  error instead of waiting for it — now drains both futures like the cold branch
- Remove pointless raw_len = len rename
This commit is contained in:
Razvan Dimescu
2026-04-12 06:42:59 +03:00
parent 72b540a44a
commit 17a1a6ddba
3 changed files with 71 additions and 93 deletions

View File

@@ -690,9 +690,30 @@ async fn send_query_hedged(
let fut_b = send_query(qname, qtype, secondary, srtt);
tokio::pin!(fut_b);
tokio::select! {
r = fut_a => r,
r = fut_b => r,
// First Ok wins; if one errors, wait for the other.
let mut a_err: Option<crate::Error> = None;
let mut b_err: Option<crate::Error> = None;
loop {
tokio::select! {
r = &mut fut_a, if a_err.is_none() => {
match r {
Ok(resp) => return Ok(resp),
Err(e) => {
if b_err.is_some() { return Err(e); }
a_err = Some(e);
}
}
}
r = &mut fut_b, if b_err.is_none() => {
match r {
Ok(resp) => return Ok(resp),
Err(e) => {
if let Some(ae) = a_err.take() { return Err(ae); }
b_err = Some(e);
}
}
}
}
}
}
}