From 2fa7a240657eb18fa2261593a1e8aa215f4063f9 Mon Sep 17 00:00:00 2001 From: Arash Sahebolamri Date: Thu, 25 Jul 2024 13:28:32 -0700 Subject: [PATCH] Address review comments: - fixed upper bound for num_worker_threads (64k) - typo --- intel-sgx/enclave-runner/src/loader.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/intel-sgx/enclave-runner/src/loader.rs b/intel-sgx/enclave-runner/src/loader.rs index 6e523e5e5..6944c5f87 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,11 @@ 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); - 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();