Skip to content

Commit d9bd492

Browse files
committed
Make it possible to disable execution timeouts
This ensures that setting an execution timeout of 0 disables execution timeouts entirely. This is temporary, as we intend to remove the wall-clock timeout feature from Hyperlight entirely in the near future.
1 parent 44e6654 commit d9bd492

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,20 @@ impl HypervisorHandler {
622622
// from the handler thread, as the thread may be paused by gdb.
623623
// In this case, we will wait indefinitely for a message from the handler thread.
624624
// Note: This applies to all the running sandboxes, not just the one being debugged.
625-
#[cfg(gdb)]
626-
let response = self.communication_channels.from_handler_rx.recv();
627625
#[cfg(not(gdb))]
628-
let response = self
629-
.communication_channels
630-
.from_handler_rx
631-
.recv_timeout(self.execution_variables.get_timeout()?);
626+
let timeout = self.execution_variables.get_timeout()?;
627+
#[cfg(gdb)]
628+
let timeout = Duration::ZERO;
629+
let response = if timeout.is_zero() {
630+
self.communication_channels
631+
.from_handler_rx
632+
.recv()
633+
.map_err(Into::into)
634+
} else {
635+
self.communication_channels
636+
.from_handler_rx
637+
.recv_timeout(timeout)
638+
};
632639

633640
match response {
634641
Ok(msg) => match msg {

src/hyperlight_host/src/sandbox/config.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,15 @@ impl SandboxConfiguration {
295295
self.kernel_stack_size = max(kernel_stack_size, Self::MIN_KERNEL_STACK_SIZE);
296296
}
297297

298-
/// Set the maximum execution time of a guest function execution. If set to 0, the max_execution_time
299-
/// will be set to the default value of DEFAULT_MAX_EXECUTION_TIME if the guest execution does not complete within the time specified
300-
/// then the execution will be cancelled, the minimum value is MIN_MAX_EXECUTION_TIME
298+
/// Set the maximum execution time of a guest function
299+
/// execution. If set to 0, the maximum execution time will be
300+
/// unlimited. If the guest execution does not complete within the
301+
/// time specified, then the execution will be cancelled. The
302+
/// minimum value is MIN_MAX_EXECUTION_TIME
301303
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
302304
pub fn set_max_execution_time(&mut self, max_execution_time: Duration) {
303305
match max_execution_time.as_millis() {
304-
0 => self.max_execution_time = Self::DEFAULT_MAX_EXECUTION_TIME,
306+
0 => self.max_execution_time = 0,
305307
1.. => {
306308
self.max_execution_time = min(
307309
Self::MAX_MAX_EXECUTION_TIME.into(),

0 commit comments

Comments
 (0)