etmem/0017-do-not-stop-the-process-when-failed-to-delete-any-obj.patch
YangXin ce6533c4bd Update etmem.
Signed-off-by: YangXin <245051644@qq.com>
2021-09-30 22:57:41 +08:00

74 lines
2.5 KiB
Diff

From 598735e135a95bf646da66708bab80a673f1344f Mon Sep 17 00:00:00 2001
From: louhongxiang <louhongxiang@huawei.com>
Date: Thu, 29 Apr 2021 15:28:22 +0800
Subject: [PATCH 17/50] do not stop the process when failed to delete any obj,
continue to delte the next one in config file specified.
---
src/etmemd_src/etmemd_rpc.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/etmemd_src/etmemd_rpc.c b/src/etmemd_src/etmemd_rpc.c
index a8653e2..8360f5a 100644
--- a/src/etmemd_src/etmemd_rpc.c
+++ b/src/etmemd_src/etmemd_rpc.c
@@ -94,11 +94,12 @@ struct obj_cmd_item {
enum opt_result (*func)(GKeyFile *config);
};
-static enum opt_result do_obj_cmd(GKeyFile *config, struct obj_cmd_item *items, unsigned n)
+static enum opt_result do_obj_cmd(GKeyFile *config, struct obj_cmd_item *items, unsigned n,bool add_opt)
{
unsigned i;
bool parsed = false;
enum opt_result ret;
+ enum opt_result err_ret = OPT_SUCCESS;
for (i = 0; i < n; i++) {
if (g_key_file_has_group(config, items[i].name) == FALSE) {
@@ -108,7 +109,10 @@ static enum opt_result do_obj_cmd(GKeyFile *config, struct obj_cmd_item *items,
ret = items[i].func(config);
if (ret != 0) {
etmemd_log(ETMEMD_LOG_ERR, "parse group %s fail\n", items[i].name);
- return ret;
+ if (add_opt) {
+ return ret;
+ }
+ err_ret = ret;
}
parsed = true;
}
@@ -118,6 +122,11 @@ static enum opt_result do_obj_cmd(GKeyFile *config, struct obj_cmd_item *items,
return OPT_INVAL;
}
+ if (err_ret != OPT_SUCCESS) {
+ etmemd_log(ETMEMD_LOG_ERR, "error occurs in %s operation\n", add_opt ? "add" : "del");
+ return err_ret;
+ }
+
return OPT_SUCCESS;
}
@@ -129,7 +138,7 @@ struct obj_cmd_item g_obj_add_items[] = {
static enum opt_result do_obj_add(GKeyFile *config)
{
- return do_obj_cmd(config, g_obj_add_items, ARRAY_SIZE(g_obj_add_items));
+ return do_obj_cmd(config, g_obj_add_items, ARRAY_SIZE(g_obj_add_items), true);
}
static struct obj_cmd_item obj_remove_items[] = {
@@ -140,7 +149,7 @@ static struct obj_cmd_item obj_remove_items[] = {
static enum opt_result do_obj_remove(GKeyFile *config)
{
- return do_obj_cmd(config, obj_remove_items, ARRAY_SIZE(obj_remove_items));
+ return do_obj_cmd(config, obj_remove_items, ARRAY_SIZE(obj_remove_items), false);
}
static enum opt_result handle_obj_cmd(char *file_name, enum cmd_type type)
--
2.27.0