Skip to content

Commit

Permalink
feat: put hook results in the front of the input stream (#973)
Browse files Browse the repository at this point in the history
Hook results must be accessed immediately after calling.

One no longer has to rely on the `input_stream` being empty when calling a hook and accessing its results.
  • Loading branch information
tqn authored Jun 24, 2024
1 parent c4cbfd1 commit 85671d6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/syscall/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ impl Syscall for SyscallWrite {
rt.state.input_stream.push(slice.to_vec());
} else if let Some(mut hook) = rt.hook_registry.get(&fd) {
let res = hook.invoke_hook(rt.hook_env(), slice);
rt.state.input_stream.extend(res);
// Add result vectors to the beginning of the stream.
let ptr = rt.state.input_stream_ptr;
rt.state.input_stream.splice(ptr..ptr, res);
} else {
log::warn!("tried to write to unknown file descriptor {fd}");
}
Expand Down

0 comments on commit 85671d6

Please sign in to comment.