From 5d75584e32eb5419ed915a9a5c554fa184e63682 Mon Sep 17 00:00:00 2001 From: "Hui, Chunyang" Date: Wed, 22 Jun 2022 10:45:21 +0000 Subject: [PATCH] Stop interrupt thread before destroying the enclave when error --- src/pal/include/occlum_pal_api.h | 2 +- src/pal/src/pal_api.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pal/include/occlum_pal_api.h b/src/pal/include/occlum_pal_api.h index 967a0213..db9eced1 100644 --- a/src/pal/include/occlum_pal_api.h +++ b/src/pal/include/occlum_pal_api.h @@ -161,7 +161,7 @@ int occlum_pal_exec(struct occlum_pal_exec_args *args); int occlum_pal_kill(int pid, int sig); /* - * @brief Destroy teh Occlum enclave + * @brief Destroy the Occlum enclave * * @retval if 0, then success; otherwise, check errno for the exact error type. */ diff --git a/src/pal/src/pal_api.c b/src/pal/src/pal_api.c index b1c6dc2d..0eafcaf0 100644 --- a/src/pal/src/pal_api.c +++ b/src/pal/src/pal_api.c @@ -148,10 +148,15 @@ int occlum_pal_init(const struct occlum_pal_attr *attr) { if (pal_run_init_process() < 0) { PAL_ERROR("Failed to run the init process: %s", errno2str(errno)); - goto on_destroy_enclave; + goto stop_interrupt_thread; } return 0; + +stop_interrupt_thread: + if (pal_interrupt_thread_stop() < 0) { + PAL_WARN("Cannot stop the interrupt thread: %s", errno2str(errno)); + } on_destroy_enclave: if (pal_destroy_enclave() < 0) { PAL_WARN("Cannot destroy the enclave");