-
Notifications
You must be signed in to change notification settings - Fork 158
Improve InterruptHandle::kill() documentation and clarify boolean return value #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
f936bc0
c34ddfa
c8e471e
5350a8c
ad4591d
0daa0fd
21cdb54
28890e7
8b7a60c
533f3a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,8 +208,17 @@ pub(crate) trait InterruptHandleImpl: InterruptHandle { | |
| pub trait InterruptHandle: Send + Sync + Debug { | ||
| /// Interrupt the corresponding sandbox from running. | ||
| /// | ||
| /// - If this is called while the the sandbox currently executing a guest function call, it will interrupt the sandbox and return `true`. | ||
| /// - If this is called while the sandbox is not running (for example before or after calling a guest function), it will do nothing and return `false`. | ||
| /// This method sets a cancellation flag that prevents or stops the execution of guest code. | ||
| /// | ||
| /// # Return Value | ||
| /// | ||
| /// The return value indicates whether a signal was sent to interrupt a running vCPU: | ||
| /// - On Linux: Returns `true` if a signal was sent to the vCPU thread, `false` if the vCPU was not running. | ||
| /// - On Windows: Returns `true` if `WHvCancelRunVirtualProcessor` was called successfully, `false` otherwise. | ||
| /// | ||
| /// **Important**: A return value of `false` does not mean the cancellation failed. The cancellation flag is | ||
| /// always set, which will prevent or stop execution. A `false` return simply means no signal was sent because | ||
| /// the vCPU was not actively running at that moment. | ||
|
||
| /// | ||
| /// # Note | ||
| /// This function will block for the duration of the time it takes for the vcpu thread to be interrupted. | ||
|
|
@@ -542,7 +551,14 @@ impl InterruptHandle for WindowsInterruptHandle { | |
| return false; | ||
| } | ||
|
|
||
| unsafe { WHvCancelRunVirtualProcessor(guard.handle, 0, 0).is_ok() } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Lets skip this, we have logging in other places
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the error logging for WHvCancelRunVirtualProcessor in commit 8b7a60c. The method now simply returns |
||
| let result = unsafe { WHvCancelRunVirtualProcessor(guard.handle, 0, 0) }; | ||
| match result { | ||
| Ok(_) => true, | ||
| Err(e) => { | ||
| log::error!("Failed to cancel running virtual processor: {}", e); | ||
| false | ||
| } | ||
| } | ||
| } | ||
| #[cfg(gdb)] | ||
| fn kill_from_debugger(&self) -> bool { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot don't make these changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted Cargo.toml changes in commit 28890e7. The tracing-tracy dependency is now back to being a regular dev-dependency as it was originally.