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
+13 -15
View File
@@ -50,22 +50,20 @@ impl ProtocolEndpoint {
message: DataMessage,
) -> Result<EndpointOutcome, EndpointError> {
let hook_id = header.hook_id.expect("validated");
let key = if let Some(key) =
self.hooks
.resolve_active_key(&self.path, hook_id, &header.src_path)
let host_key = HookKey::new(self.path.clone(), hook_id);
let key = if let Some(key) = self
.hooks
.resolve_active_key_for_host(&host_key, &header.src_path)
{
key
} else if self.hooks.pending(&host_key).is_some_and(|pending| {
pending.caller_src_path == header.src_path
&& pending.procedure_id == message.procedure_id
}) {
self.hooks.activate_pending(&host_key);
host_key
} else {
let pending_key = HookKey::new(self.path.clone(), hook_id);
if self.hooks.pending(&pending_key).is_some_and(|pending| {
pending.caller_src_path == header.src_path
&& pending.procedure_id == message.procedure_id
}) {
self.hooks.activate_pending(&pending_key);
pending_key
} else {
return Ok(EndpointOutcome::Dropped);
}
return Ok(EndpointOutcome::Dropped);
};
let Some(active) = self.hooks.active(&key) else {
@@ -101,9 +99,10 @@ impl ProtocolEndpoint {
message: FaultMessage,
) -> Result<EndpointOutcome, EndpointError> {
let hook_id = header.hook_id.expect("validated");
let pending_key = HookKey::new(self.path.clone(), hook_id);
if let Some(key) = self
.hooks
.resolve_active_key(&self.path, hook_id, &header.src_path)
.resolve_active_key_for_host(&pending_key, &header.src_path)
{
self.hooks.remove_active(&key);
return Ok(EndpointOutcome::Local(LocalEvent::Fault {
@@ -113,7 +112,6 @@ impl ProtocolEndpoint {
}));
}
let pending_key = HookKey::new(self.path.clone(), hook_id);
if self
.hooks
.pending(&pending_key)