Skip to content

Commit

Permalink
Address review comments:
Browse files Browse the repository at this point in the history
- fixed upper bound for num_worker_threads (64k)
- typo
  • Loading branch information
Arash Sahebolamri committed Jul 25, 2024
1 parent cbe6600 commit 2fa7a24
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions intel-sgx/enclave-runner/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a> EnclaveBuilder<'a> {
self
}

/// Sets the number of wroker threads used to run the enclave.
/// Sets the number of worker threads used to run the enclave.
///
/// **NOTE:** This is only applicable to [`Command`] enclaves.
/// Setting this and then calling [`build_library`](Self::build_library) will cause a panic.
Expand Down Expand Up @@ -342,10 +342,11 @@ impl<'a> EnclaveBuilder<'a> {
}

pub fn build<T: Load>(mut self, loader: &mut T) -> Result<Command, anyhow::Error> {
let num_cpus = num_cpus::get();
let num_worker_threads = self.num_worker_threads.unwrap_or(num_cpus);
anyhow::ensure!(num_worker_threads > 0, "`num_worker_threads` cannot be zero");
anyhow::ensure!(num_worker_threads <= num_cpus, "`num_worker_threads` cannot exceed number of logical cores (`num_cpus::get()`)");
if let Some(num_worker_threads) = self.num_worker_threads {
anyhow::ensure!(num_worker_threads > 0, "`num_worker_threads` cannot be zero");
anyhow::ensure!(num_worker_threads <= 65536, "`num_worker_threads` cannot exceed 65536");
}
let num_worker_threads = self.num_worker_threads.unwrap_or_else(num_cpus::get);

self.initialized_args_mut();
let args = self.cmd_args.take().unwrap_or_default();
Expand Down

0 comments on commit 2fa7a24

Please sign in to comment.