Reuse host hook keys during inbound hook resolution

This commit is contained in:
Michael Mikovsky
2026-04-25 23:42:28 -06:00
parent 4c790a4ad3
commit e50ebb1e35
2 changed files with 25 additions and 18 deletions
+12 -3
View File
@@ -183,17 +183,26 @@ impl HookTable {
return_path: &[String],
hook_id: u64,
peer_path: &[String],
) -> Option<HookKey> {
let host_key = HookKey::new(return_path.to_vec(), hook_id);
self.resolve_active_key_for_host(&host_key, peer_path)
}
#[must_use]
pub fn resolve_active_key_for_host(
&self,
host_key: &HookKey,
peer_path: &[String],
) -> Option<HookKey> {
if let Some(key) = self
.active_by_peer
.get(&hook_id)
.get(&host_key.hook_id)
.and_then(|peer_paths| peer_paths.get(peer_path))
{
return Some(key.clone());
}
let host_key = HookKey::new(return_path.to_vec(), hook_id);
self.active.contains_key(&host_key).then_some(host_key)
self.active.contains_key(host_key).then(|| host_key.clone())
}
/// Marks the local side finished and returns `true` once both sides are finished.