From 4fd27d45433f82e90677332b0f4a13cda7db9305 Mon Sep 17 00:00:00 2001 From: Arash Sahebolamri Date: Fri, 19 Jul 2024 10:53:58 -0700 Subject: [PATCH] Address review comments: - typo - fixed upper bound for num_worker_threads --- intel-sgx/enclave-runner/src/loader.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/intel-sgx/enclave-runner/src/loader.rs b/intel-sgx/enclave-runner/src/loader.rs index 6e523e5e..e99fc345 100644 --- a/intel-sgx/enclave-runner/src/loader.rs +++ b/intel-sgx/enclave-runner/src/loader.rs @@ -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. @@ -342,10 +342,9 @@ impl<'a> EnclaveBuilder<'a> { } pub fn build(mut self, loader: &mut T) -> Result { - let num_cpus = num_cpus::get(); - let num_worker_threads = self.num_worker_threads.unwrap_or(num_cpus); + let num_worker_threads = self.num_worker_threads.unwrap_or_else(num_cpus::get); 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()`)"); + anyhow::ensure!(num_worker_threads <= 512, "`num_worker_threads` cannot exceed 512"); self.initialized_args_mut(); let args = self.cmd_args.take().unwrap_or_default();