From 3c3197390d14cc94e3e0117969ab8c70d0976dd0 Mon Sep 17 00:00:00 2001 From: jinlun Date: Mon, 17 Jun 2024 20:28:35 +0800 Subject: [PATCH 07/14] fix resource clear in concurrent scenarios --- src/common/dim_entry.c | 13 ++++++++++++- src/core/dim_core_main.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/common/dim_entry.c b/src/common/dim_entry.c index a8dcae7..f2454ce 100644 --- a/src/common/dim_entry.c +++ b/src/common/dim_entry.c @@ -4,9 +4,12 @@ #include #include +#include #include "dim_entry.h" +#define WAIT_TIME_MAX 1000 + int dim_entry_create(struct dim_entry *entry, struct dentry *parent) { int ret = 0; @@ -27,7 +30,15 @@ int dim_entry_create(struct dim_entry *entry, struct dentry *parent) void dim_entry_remove(struct dim_entry *entry) { + int time_ms = 0; + if (entry != NULL && entry->dentry != NULL) { + while (d_is_dir(entry->dentry) && + !simple_empty(entry->dentry) && + time_ms < WAIT_TIME_MAX) { + time_ms++; + msleep(1); + } securityfs_remove(entry->dentry); entry->dentry = NULL; } @@ -60,4 +71,4 @@ void dim_entry_remove_list(struct dim_entry **list, unsigned int len) for (i = 0; i < len; i++) dim_entry_remove(list[i]); -} \ No newline at end of file +} diff --git a/src/core/dim_core_main.c b/src/core/dim_core_main.c index de18d66..d4cc870 100644 --- a/src/core/dim_core_main.c +++ b/src/core/dim_core_main.c @@ -91,8 +91,8 @@ err: static void __exit dim_core_exit(void) { - dim_core_measure_destroy(); dim_core_destroy_fs(); + dim_core_measure_destroy(); dim_mem_pool_destroy(); if (signature) -- 2.33.0