mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-09 06:47:59 -06:00
Shortcut pending hook activation on first data
This commit is contained in:
@@ -60,8 +60,18 @@ impl ProtocolEndpoint {
|
|||||||
pending.caller_src_path == header.src_path
|
pending.caller_src_path == header.src_path
|
||||||
&& pending.procedure_id == message.procedure_id
|
&& pending.procedure_id == message.procedure_id
|
||||||
}) {
|
}) {
|
||||||
self.hooks.activate_pending(&host_key);
|
let local_ended = self
|
||||||
host_key
|
.hooks
|
||||||
|
.activate_pending_with_peer_end(&host_key, message.end_hook)
|
||||||
|
.expect("pending hook was checked above");
|
||||||
|
if message.end_hook && local_ended {
|
||||||
|
self.hooks.remove_active(&host_key);
|
||||||
|
}
|
||||||
|
return Ok(EndpointOutcome::Local(LocalEvent::Data {
|
||||||
|
header,
|
||||||
|
message,
|
||||||
|
hook_key: host_key,
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
return Ok(EndpointOutcome::Dropped);
|
return Ok(EndpointOutcome::Dropped);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,18 +98,29 @@ impl HookTable {
|
|||||||
/// Activation intentionally reuses the original hook id and host path, but swaps the
|
/// Activation intentionally reuses the original hook id and host path, but swaps the
|
||||||
/// pending caller attribution into the active peer path used for data routing.
|
/// pending caller attribution into the active peer path used for data routing.
|
||||||
pub fn activate_pending(&mut self, key: &HookKey) -> Option<()> {
|
pub fn activate_pending(&mut self, key: &HookKey) -> Option<()> {
|
||||||
|
self.activate_pending_with_peer_end(key, false).map(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Promotes a pending hook into the active table and returns whether the local side had
|
||||||
|
/// already ended before the peer accepted the hook.
|
||||||
|
pub fn activate_pending_with_peer_end(
|
||||||
|
&mut self,
|
||||||
|
key: &HookKey,
|
||||||
|
peer_ended: bool,
|
||||||
|
) -> Option<bool> {
|
||||||
let pending = self.pending.remove(key)?;
|
let pending = self.pending.remove(key)?;
|
||||||
|
let local_ended = pending.local_ended;
|
||||||
self.insert_active(
|
self.insert_active(
|
||||||
key.clone(),
|
key.clone(),
|
||||||
ActiveHook {
|
ActiveHook {
|
||||||
peer_path: pending.caller_src_path,
|
peer_path: pending.caller_src_path,
|
||||||
procedure_id: pending.procedure_id,
|
procedure_id: pending.procedure_id,
|
||||||
local_ended: pending.local_ended,
|
local_ended,
|
||||||
peer_ended: false,
|
peer_ended,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.ok()?;
|
.ok()?;
|
||||||
Some(())
|
Some(local_ended)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a live hook and its peer-path lookup entry.
|
/// Inserts a live hook and its peer-path lookup entry.
|
||||||
|
|||||||
Reference in New Issue
Block a user