iopsys-feed/obuspa/patches/1001-use-datamodel-caching.patch
2025-04-30 19:52:40 +05:30

66 lines
2.5 KiB
Diff

commit 7bb794c3d8bbdcf4aa39f8c28f1fabcda11487b9
Author: Vivek Kumar Dutta <vivek.dutta@iopsys.eu>
Date: Wed Apr 30 17:18:27 2025 +0530
1001-use-datamodel-caching.patch
diff --git a/src/core/cli_server.c b/src/core/cli_server.c
index da61c6f..abac7cb 100644
--- a/src/core/cli_server.c
+++ b/src/core/cli_server.c
@@ -511,6 +511,7 @@ int CLI_SERVER_ExecuteCliCommand(char *cmd_line)
SendCliResponse("WARNING: Discarding unused args: %s\n", args.vector[cli_cmd->max_args+1]);
}
+ vendor_create_dm_cache(NULL, 0);
// Process command
err = cli_cmd->exec_cmd(&args);
print_help = false;
@@ -670,6 +671,11 @@ int ExecuteCli_Version(str_vector_t *args)
int ExecuteCli_Get(str_vector_t *args)
{
combined_role_t *combined_role;
+
+ char *path[2] = {args->vector[1], 0};
+
+ vendor_create_dm_cache(path, 1);
+
#ifndef REMOVE_USP_BROKER
char *arg1;
diff --git a/src/core/data_model.h b/src/core/data_model.h
index 7564127..2736d7c 100755
--- a/src/core/data_model.h
+++ b/src/core/data_model.h
@@ -405,5 +405,6 @@ int DM_PRIV_ReRegister_DBParam_Default(char *path, char *value);
bool DM_PRIV_IsChildNodeOf(dm_node_t *node, dm_node_t *parent_node);
void DM_PRIV_GetAllEventsAndCommands(dm_node_t *node, str_vector_t *events, str_vector_t *commands);
+int vendor_create_dm_cache(char *paths[], int num_paths);
#endif
diff --git a/src/core/handle_get.c b/src/core/handle_get.c
index d9d3e9e..c263978 100644
--- a/src/core/handle_get.c
+++ b/src/core/handle_get.c
@@ -129,6 +129,7 @@ void MSG_HANDLER_HandleGet(Usp__Msg *usp, char *controller_endpoint, mtp_conn_t
goto exit;
}
+ vendor_create_dm_cache(path_exprs, num_path_expr);
// Calculate the number of hierarchical levels to traverse in the data model when performing partial path resolution
// NOTE: protocol buffer has depth as an unsigned quantity, but internally we use a signed number, so limit range to that of a signed number
depth = usp->body->request->get->max_depth;
diff --git a/src/core/msg_handler.c b/src/core/msg_handler.c
index 647591d..b7498d8 100755
--- a/src/core/msg_handler.c
+++ b/src/core/msg_handler.c
@@ -863,6 +863,8 @@ int HandleUspMessage(Usp__Msg *usp, char *endpoint_id, mtp_conn_t *mtpc)
MSG_HANDLER_UspMsgTypeToString(usp->header->msg_type),
iso8601_cur_time(buf, sizeof(buf)) );
+ // Drop the cached data before processing next message
+ vendor_create_dm_cache(NULL, 0);
// Process the message
cur_msg_type = usp_msg_type;
switch(usp_msg_type)