mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-09 12:02:14 +00:00
shaping: micro-optimize get_egress_path_config impl w/ providers
We make two passes over the provider data; the first to get the base provider stuff which can theoretically match multiple provider records, then a second to apply provider-source data over the top of that. That second pass should ideally hit the DNS cache for any of the providers that we checked in the first pass, but it is theoretically possible for entries to be pushed out of the cache or expire in the intervening time. Let's just keep a local note of what we want to include to avoid that possibility; it also shaves off some micro cpu overhead to decide what should apply.
This commit is contained in:
@@ -289,23 +289,27 @@ impl ShapingInner {
|
||||
// TSA http "domain name" here
|
||||
let is_domain_name = dns_resolver::Name::from_str_relaxed(domain).is_ok();
|
||||
if is_domain_name {
|
||||
let mut prov_with_sources = vec![];
|
||||
|
||||
for prov in self.by_provider.values() {
|
||||
if prov.domain_matches(domain).await {
|
||||
toml_table_merge_from(&mut params.params, &prov.params);
|
||||
prov.apply_provider_params_to(egress_source, &mut params.params);
|
||||
|
||||
if !prov.sources.is_empty() {
|
||||
// Remember this matching provider, so that we
|
||||
// can apply any source rules after we've applied
|
||||
// any/all base provider rules for this domain
|
||||
prov_with_sources.push(prov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then Provider source rules
|
||||
for prov in self.by_provider.values() {
|
||||
if prov.sources.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if prov.domain_matches(domain).await {
|
||||
if let Some(source) = prov.sources.get(egress_source) {
|
||||
toml_table_merge_from(&mut params.params, &source);
|
||||
prov.apply_provider_params_to(egress_source, &mut params.params);
|
||||
}
|
||||
for prov in prov_with_sources {
|
||||
if let Some(source) = prov.sources.get(egress_source) {
|
||||
toml_table_merge_from(&mut params.params, &source);
|
||||
prov.apply_provider_params_to(egress_source, &mut params.params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user