From a8c0948546ef992fc3f9796bd7f9f831252eee4c Mon Sep 17 00:00:00 2001 From: Hu Yueh-Wei Date: Thu, 7 Nov 2024 16:59:05 +0800 Subject: [PATCH] fix: refine codes --- .vscode/launch.json | 2 +- core/include/ten_utils/lib/string.h | 25 ++++++- core/include/ten_utils/value/value_string.h | 2 + .../include_internal/ten_runtime/common/loc.h | 11 +++ .../ten_utils/value/value_set.h | 5 +- core/src/ten_runtime/addon/addon.c | 2 +- core/src/ten_runtime/addon/addon_autoload.c | 1 + core/src/ten_runtime/addon/ten_env/on_xxx.c | 4 +- core/src/ten_runtime/app/metadata.c | 2 +- core/src/ten_runtime/common/loc.c | 75 +++++++++++++------ .../ten_runtime/msg/cmd_base/cmd/custom/cmd.c | 4 +- .../msg/cmd_base/cmd/start_graph/cmd.c | 4 +- .../ten_runtime/msg/cmd_base/cmd/timer/cmd.c | 2 +- core/src/ten_runtime/msg/cmd_base/cmd_base.c | 30 ++++---- .../ten_runtime/msg/cmd_base/cmd_result/cmd.c | 3 + .../ten_runtime/msg/cmd_base/field/cmd_id.c | 2 +- .../ten_runtime/msg/cmd_base/field/seq_id.c | 2 +- core/src/ten_runtime/msg/field/src.c | 4 +- core/src/ten_runtime/msg/msg.c | 4 +- .../msg_conversion/per_property/rule.c | 2 +- .../msg_conversion/msg_conversion_context.c | 3 +- core/src/ten_runtime/path/path.c | 2 + core/src/ten_runtime/path/path_table.c | 6 ++ core/src/ten_runtime/timer/timer.c | 3 +- core/src/ten_utils/io/general/socket.c | 4 +- core/src/ten_utils/lib/sys/general/string.c | 58 +++++++++++--- core/src/ten_utils/value/value.c | 40 +++++++++- core/src/ten_utils/value/value_path.c | 8 +- core/src/ten_utils/value/value_set.c | 18 ++++- core/src/ten_utils/value/value_string.c | 8 ++ .../extension_test/timer/timer_one_shot.cc | 8 +- 31 files changed, 261 insertions(+), 83 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 099461e2e..a688a2077 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -137,7 +137,7 @@ "request": "launch", "program": "${workspaceFolder}/out/linux/x64/tests/standalone/ten_runtime_smoke_test", "args": [ - "--gtest_filter=CmdConversionTest.CmdConversionConnectCmd" + "--gtest_filter=AudioFrameTest.FromJson" ], "cwd": "${workspaceFolder}/out/linux/x64/tests/standalone/", "env": { diff --git a/core/include/ten_utils/lib/string.h b/core/include/ten_utils/lib/string.h index 9c2c9c9fd..3c640a916 100644 --- a/core/include/ten_utils/lib/string.h +++ b/core/include/ten_utils/lib/string.h @@ -17,7 +17,12 @@ #include "ten_utils/macro/check.h" #define TEN_STRING_SIGNATURE 0x178445C0402E320DU -#define TEN_STRING_PRE_BUF_SIZE 512 + +#if defined(NDEBUG) +#define TEN_STRING_PRE_BUF_SIZE 256 +#else +#define TEN_STRING_PRE_BUF_SIZE 8 +#endif typedef struct ten_list_t ten_list_t; @@ -36,9 +41,16 @@ inline bool ten_string_check_integrity(const ten_string_t *self) { if (ten_signature_get(&self->signature) != TEN_STRING_SIGNATURE) { return false; } + + if (self->buf == NULL) { + return false; + } + return true; } +TEN_UTILS_API bool ten_string_buf_needs_free(ten_string_t *self); + /** * @brief Create a string object. * @return A pointer to the string object. @@ -79,6 +91,10 @@ TEN_UTILS_API void ten_string_init(ten_string_t *self); TEN_UTILS_API void ten_string_init_formatted(ten_string_t *self, const char *fmt, ...); +TEN_UTILS_API void ten_string_copy_construct(ten_string_t *self, + ten_string_t *other); + +// =-=-= 整理 ten_string_copy 的意义 /** * @brief Initialize a string object from another string object. * @param self The string object. @@ -93,7 +109,10 @@ TEN_UTILS_API void ten_string_copy(ten_string_t *self, ten_string_t *other); * @param size the max size, copy all if size <= 0 */ TEN_UTILS_API void ten_string_init_from_c_str(ten_string_t *self, - const char *other, size_t size); + const char *str, size_t size); + +TEN_UTILS_API void ten_string_set_from_c_str(ten_string_t *self, + const char *str, size_t size); /** * @brief Destroy a string object and release the memory. @@ -101,6 +120,8 @@ TEN_UTILS_API void ten_string_init_from_c_str(ten_string_t *self, */ TEN_UTILS_API void ten_string_destroy(ten_string_t *self); +TEN_UTILS_API void ten_string_reset(ten_string_t *self); + /** * @brief Destroy a string object, left the memory. * @param self The string object. diff --git a/core/include/ten_utils/value/value_string.h b/core/include/ten_utils/value/value_string.h index a40697dd7..64e0c0da1 100644 --- a/core/include/ten_utils/value/value_string.h +++ b/core/include/ten_utils/value/value_string.h @@ -19,3 +19,5 @@ TEN_UTILS_API bool ten_value_to_string(ten_value_t *self, ten_string_t *str, TEN_UTILS_API ten_value_t *ten_value_from_type_and_string(TEN_TYPE type, const char *str, ten_error_t *err); + +TEN_UTILS_API bool ten_value_string_buf_needs_free(ten_value_t *self); diff --git a/core/include_internal/ten_runtime/common/loc.h b/core/include_internal/ten_runtime/common/loc.h index b3146a23a..40ff52147 100644 --- a/core/include_internal/ten_runtime/common/loc.h +++ b/core/include_internal/ten_runtime/common/loc.h @@ -52,17 +52,28 @@ TEN_RUNTIME_PRIVATE_API ten_loc_t *ten_loc_clone(ten_loc_t *src); TEN_RUNTIME_PRIVATE_API void ten_loc_copy(ten_loc_t *self, ten_loc_t *src); +TEN_RUNTIME_PRIVATE_API void ten_loc_init(ten_loc_t *self, const char *app_uri, + const char *graph_id, + const char *extension_group_name, + const char *extension_name); + TEN_RUNTIME_PRIVATE_API void ten_loc_init_from_loc(ten_loc_t *self, ten_loc_t *src); TEN_RUNTIME_PRIVATE_API void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value); +TEN_RUNTIME_PRIVATE_API void ten_loc_set_from_value(ten_loc_t *self, + ten_value_t *value); + TEN_RUNTIME_PRIVATE_API void ten_loc_set(ten_loc_t *self, const char *app_uri, const char *graph_id, const char *extension_group_name, const char *extension_name); +TEN_RUNTIME_PRIVATE_API void ten_loc_set_from_loc(ten_loc_t *self, + ten_loc_t *src); + TEN_RUNTIME_PRIVATE_API bool ten_loc_is_empty(ten_loc_t *self); TEN_RUNTIME_PRIVATE_API void ten_loc_clear(ten_loc_t *self); diff --git a/core/include_internal/ten_utils/value/value_set.h b/core/include_internal/ten_utils/value/value_set.h index f7063c055..398d22210 100644 --- a/core/include_internal/ten_utils/value/value_set.h +++ b/core/include_internal/ten_utils/value/value_set.h @@ -34,7 +34,10 @@ TEN_UTILS_API bool ten_value_set_float32(ten_value_t *self, float value); TEN_UTILS_API bool ten_value_set_float64(ten_value_t *self, double value); -TEN_UTILS_API bool ten_value_set_string(ten_value_t *self, const char *value); +TEN_UTILS_API bool ten_value_set_string(ten_value_t *self, const char *str); + +TEN_UTILS_API bool ten_value_set_string_with_size(ten_value_t *self, + const char *str, size_t len); TEN_UTILS_API bool ten_value_set_array_with_move(ten_value_t *self, ten_list_t *value); diff --git a/core/src/ten_runtime/addon/addon.c b/core/src/ten_runtime/addon/addon.c index 06f2ac793..8d6453200 100644 --- a/core/src/ten_runtime/addon/addon.c +++ b/core/src/ten_runtime/addon/addon.c @@ -517,7 +517,7 @@ void ten_addon_find_and_set_base_dir(ten_addon_host_t *self, // If the addon's base dir cannot be found by searching upward through the // parent folders, simply trust the passed-in parameter as the addon’s base // dir. - ten_string_init_from_c_str(&self->base_dir, start_path, strlen(start_path)); + ten_string_set_from_c_str(&self->base_dir, start_path, strlen(start_path)); } } diff --git a/core/src/ten_runtime/addon/addon_autoload.c b/core/src/ten_runtime/addon/addon_autoload.c index 000edb560..c04aeb6a5 100644 --- a/core/src/ten_runtime/addon/addon_autoload.c +++ b/core/src/ten_runtime/addon/addon_autoload.c @@ -263,6 +263,7 @@ bool ten_addon_load_all_from_app_base_dir(ten_app_t *app, ten_error_t *err) { for (int i = 0; i < sizeof(folders) / sizeof(folders[0]); i++) { ten_string_t module_path; + ten_string_init(&module_path); ten_string_copy(&module_path, &app->base_dir); do { diff --git a/core/src/ten_runtime/addon/ten_env/on_xxx.c b/core/src/ten_runtime/addon/ten_env/on_xxx.c index 0ea1d0503..86f4da607 100644 --- a/core/src/ten_runtime/addon/ten_env/on_xxx.c +++ b/core/src/ten_runtime/addon/ten_env/on_xxx.c @@ -89,8 +89,8 @@ void ten_addon_on_init_done(ten_env_t *self) { // runtime would use that name instead of the name specified in the codes to // register it to the extension store. if (strlen(manifest_name)) { - ten_string_init_from_c_str(&addon_host->name, manifest_name, - strlen(manifest_name)); + ten_string_set_from_c_str(&addon_host->name, manifest_name, + strlen(manifest_name)); } } diff --git a/core/src/ten_runtime/app/metadata.c b/core/src/ten_runtime/app/metadata.c index 6b1939d24..b875ad5f5 100644 --- a/core/src/ten_runtime/app/metadata.c +++ b/core/src/ten_runtime/app/metadata.c @@ -90,7 +90,7 @@ bool ten_app_init_uri(ten_app_t *self, ten_value_t *value) { ? ten_value_peek_raw_str(value) : ten_string_get_raw_str(&default_url); - ten_string_init_from_c_str(&self->uri, url_str, strlen(url_str)); + ten_string_set_from_c_str(&self->uri, url_str, strlen(url_str)); ten_string_deinit(&default_url); diff --git a/core/src/ten_runtime/common/loc.c b/core/src/ten_runtime/common/loc.c index c3e007c99..e6c215a9e 100644 --- a/core/src/ten_runtime/common/loc.c +++ b/core/src/ten_runtime/common/loc.c @@ -60,7 +60,7 @@ ten_loc_t *ten_loc_create_from_value(ten_value_t *value) { ten_loc_t *self = ten_loc_create_empty(); - ten_loc_init_from_value(self, value); + ten_loc_set_from_value(self, value); TEN_ASSERT(ten_loc_check_integrity(self), "Should not happen."); return self; @@ -84,7 +84,7 @@ void ten_loc_copy(ten_loc_t *self, ten_loc_t *src) { TEN_ASSERT(self, "Invalid argument."); TEN_ASSERT(src && ten_loc_check_integrity(src), "Invalid argument."); - ten_loc_init_from_loc(self, src); + ten_loc_set_from_loc(self, src); } void ten_loc_destroy(ten_loc_t *self) { @@ -108,13 +108,24 @@ void ten_loc_init_empty(ten_loc_t *self) { void ten_loc_init_from_loc(ten_loc_t *self, ten_loc_t *src) { TEN_ASSERT(self && src, "Should not happen."); - ten_loc_init_empty(self); + ten_signature_set(&self->signature, TEN_LOC_SIGNATURE); + + ten_loc_init(self, ten_string_get_raw_str(&src->app_uri), + ten_string_get_raw_str(&src->graph_id), + ten_string_get_raw_str(&src->extension_group_name), + ten_string_get_raw_str(&src->extension_name)); + + TEN_ASSERT(ten_loc_check_integrity(self), "Should not happen."); +} + +void ten_loc_set_from_loc(ten_loc_t *self, ten_loc_t *src) { + TEN_ASSERT(self && ten_loc_check_integrity(self) && src, + "Should not happen."); + ten_loc_set(self, ten_string_get_raw_str(&src->app_uri), ten_string_get_raw_str(&src->graph_id), ten_string_get_raw_str(&src->extension_group_name), ten_string_get_raw_str(&src->extension_name)); - - TEN_ASSERT(ten_loc_check_integrity(self), "Should not happen."); } void ten_loc_deinit(ten_loc_t *self) { @@ -128,8 +139,9 @@ void ten_loc_deinit(ten_loc_t *self) { ten_string_deinit(&self->extension_name); } -void ten_loc_set(ten_loc_t *self, const char *app_uri, const char *graph_id, - const char *extension_group_name, const char *extension_name) { +void ten_loc_init(ten_loc_t *self, const char *app_uri, const char *graph_id, + const char *extension_group_name, + const char *extension_name) { TEN_ASSERT(self, "Should not happen."); ten_string_init_formatted(&self->app_uri, "%s", app_uri ? app_uri : ""); @@ -142,6 +154,20 @@ void ten_loc_set(ten_loc_t *self, const char *app_uri, const char *graph_id, TEN_ASSERT(ten_loc_check_integrity(self), "Should not happen."); } +void ten_loc_set(ten_loc_t *self, const char *app_uri, const char *graph_id, + const char *extension_group_name, const char *extension_name) { + TEN_ASSERT(self, "Should not happen."); + + ten_string_set_formatted(&self->app_uri, "%s", app_uri ? app_uri : ""); + ten_string_set_formatted(&self->graph_id, "%s", graph_id ? graph_id : ""); + ten_string_set_formatted(&self->extension_group_name, "%s", + extension_group_name ? extension_group_name : ""); + ten_string_set_formatted(&self->extension_name, "%s", + extension_name ? extension_name : ""); + + TEN_ASSERT(ten_loc_check_integrity(self), "Should not happen."); +} + bool ten_loc_is_empty(ten_loc_t *self) { TEN_ASSERT(self, "Should not happen."); @@ -191,12 +217,12 @@ void ten_loc_to_string(ten_loc_t *self, ten_string_t *result) { TEN_ASSERT(self && result && ten_loc_check_integrity(self), "Should not happen."); - ten_string_init_formatted(result, - "app: %s, graph: %s, group: %s, extension: %s", - ten_string_get_raw_str(&self->app_uri), - ten_string_get_raw_str(&self->graph_id), - ten_string_get_raw_str(&self->extension_group_name), - ten_string_get_raw_str(&self->extension_name)); + ten_string_set_formatted(result, + "app: %s, graph: %s, group: %s, extension: %s", + ten_string_get_raw_str(&self->app_uri), + ten_string_get_raw_str(&self->graph_id), + ten_string_get_raw_str(&self->extension_group_name), + ten_string_get_raw_str(&self->extension_name)); } void ten_loc_to_json_string(ten_loc_t *self, ten_string_t *result) { @@ -375,11 +401,9 @@ void ten_loc_init_from_json(ten_loc_t *self, ten_json_t *json) { } } -void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { +void ten_loc_set_from_value(ten_loc_t *self, ten_value_t *value) { TEN_ASSERT(self && value, "Should not happen."); - ten_loc_init_empty(self); - ten_value_t *app_value = ten_value_object_peek(value, TEN_STR_APP); ten_value_t *graph_value = ten_value_object_peek(value, TEN_STR_GRAPH); ten_value_t *extension_group_value = @@ -392,7 +416,7 @@ void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { const char *app_str = ten_value_peek_raw_str(app_value); if (app_str && strlen(app_str) > 0) { - ten_string_init_from_c_str(&self->app_uri, app_str, strlen(app_str)); + ten_string_set_from_c_str(&self->app_uri, app_str, strlen(app_str)); } } @@ -401,7 +425,7 @@ void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { const char *graph_str = ten_value_peek_raw_str(graph_value); if (graph_str && strlen(graph_str) > 0) { - ten_string_init_from_c_str(&self->graph_id, graph_str, strlen(graph_str)); + ten_string_set_from_c_str(&self->graph_id, graph_str, strlen(graph_str)); } } @@ -411,8 +435,8 @@ void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { const char *group_name_str = ten_value_peek_raw_str(extension_group_value); if (group_name_str && strlen(group_name_str) > 0) { - ten_string_init_from_c_str(&self->extension_group_name, group_name_str, - strlen(group_name_str)); + ten_string_set_from_c_str(&self->extension_group_name, group_name_str, + strlen(group_name_str)); } } @@ -421,8 +445,15 @@ void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { const char *extension_name_str = ten_value_peek_raw_str(extension_value); if (extension_name_str && strlen(extension_name_str) > 0) { - ten_string_init_from_c_str(&self->extension_name, extension_name_str, - strlen(extension_name_str)); + ten_string_set_from_c_str(&self->extension_name, extension_name_str, + strlen(extension_name_str)); } } } + +void ten_loc_init_from_value(ten_loc_t *self, ten_value_t *value) { + TEN_ASSERT(self && value, "Should not happen."); + + ten_loc_init_empty(self); + ten_loc_set_from_value(self, value); +} diff --git a/core/src/ten_runtime/msg/cmd_base/cmd/custom/cmd.c b/core/src/ten_runtime/msg/cmd_base/cmd/custom/cmd.c index 4f1e9974d..d9681560d 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd/custom/cmd.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd/custom/cmd.c @@ -16,6 +16,7 @@ #include "include_internal/ten_runtime/msg/field/field_info.h" #include "include_internal/ten_runtime/msg/msg.h" #include "include_internal/ten_utils/value/value_path.h" +#include "include_internal/ten_utils/value/value_set.h" #include "ten_runtime/common/errno.h" #include "ten_utils/container/list.h" #include "ten_utils/container/list_node.h" @@ -25,7 +26,6 @@ #include "ten_utils/lib/smart_ptr.h" #include "ten_utils/lib/string.h" #include "ten_utils/macro/check.h" -#include "ten_utils/macro/mark.h" #include "ten_utils/value/value.h" static void ten_raw_cmd_custom_destroy(ten_cmd_t *self) { @@ -233,7 +233,7 @@ bool ten_raw_cmd_custom_set_ten_property(ten_msg_t *self, ten_list_t *paths, if (!strcmp(TEN_STR_NAME, ten_string_get_raw_str(&item->obj_item_str))) { if (ten_value_is_string(value)) { - ten_value_init_string_with_size( + ten_value_set_string_with_size( &self->name, ten_value_peek_raw_str(value), strlen(ten_value_peek_raw_str(value))); success = true; diff --git a/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/cmd.c b/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/cmd.c index 64ca0133b..1b83b4edb 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/cmd.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd/start_graph/cmd.c @@ -334,8 +334,8 @@ static void ten_raw_cmd_start_graph_add_missing_extension_group_node( // Create an extension_group item that uses the builtin // default_extension_group, allowing the extension's extension_group to be // associated with an extension_group addon. - ten_string_init_formatted(&extension_group_info->extension_group_addon_name, - TEN_STR_DEFAULT_EXTENSION_GROUP); + ten_string_set_formatted(&extension_group_info->extension_group_addon_name, + TEN_STR_DEFAULT_EXTENSION_GROUP); ten_loc_set( &extension_group_info->loc, diff --git a/core/src/ten_runtime/msg/cmd_base/cmd/timer/cmd.c b/core/src/ten_runtime/msg/cmd_base/cmd/timer/cmd.c index 09f3cd44c..5ce964ee6 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd/timer/cmd.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd/timer/cmd.c @@ -257,7 +257,7 @@ bool ten_raw_cmd_timer_set_ten_property(ten_msg_t *self, ten_list_t *paths, } else if (!strcmp(TEN_STR_NAME, ten_string_get_raw_str(&item->obj_item_str))) { if (ten_value_is_string(value)) { - ten_value_init_string_with_size( + ten_value_set_string_with_size( &self->name, ten_value_peek_raw_str(value), strlen(ten_value_peek_raw_str(value))); success = true; diff --git a/core/src/ten_runtime/msg/cmd_base/cmd_base.c b/core/src/ten_runtime/msg/cmd_base/cmd_base.c index 0d7de85ea..28d4604ca 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd_base.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd_base.c @@ -75,33 +75,33 @@ void ten_raw_cmd_base_init(ten_cmd_base_t *self, TEN_MSG_TYPE type) { switch (type) { case TEN_MSG_TYPE_CMD_START_GRAPH: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_START_GRAPH); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_START_GRAPH); break; case TEN_MSG_TYPE_CMD_TIMEOUT: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_TIMEOUT); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_TIMEOUT); break; case TEN_MSG_TYPE_CMD_TIMER: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_TIMER); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_TIMER); break; case TEN_MSG_TYPE_CMD_STOP_GRAPH: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_STOP_GRAPH); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_STOP_GRAPH); break; case TEN_MSG_TYPE_CMD_CLOSE_APP: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_CLOSE_APP); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_CLOSE_APP); break; case TEN_MSG_TYPE_CMD_RESULT: - ten_string_init_formatted(ten_value_peek_string(&self->msg_hdr.name), - "%s", TEN_STR_MSG_NAME_TEN_RESULT); + ten_string_set_formatted(ten_value_peek_string(&self->msg_hdr.name), "%s", + TEN_STR_MSG_NAME_TEN_RESULT); break; default: @@ -120,6 +120,8 @@ void ten_raw_cmd_base_deinit(ten_cmd_base_t *self) { ten_value_deinit(&self->cmd_id); ten_value_deinit(&self->seq_id); + ten_string_deinit(&self->parent_cmd_id); + self->original_connection = NULL; } @@ -213,7 +215,7 @@ const char *ten_cmd_base_gen_new_cmd_id_forcibly(ten_shared_ptr_t *self) { void ten_raw_cmd_base_set_cmd_id(ten_cmd_base_t *self, const char *cmd_id) { TEN_ASSERT(self && ten_raw_cmd_base_check_integrity(self) && cmd_id, "Should not happen."); - ten_string_init_formatted(ten_value_peek_string(&self->cmd_id), "%s", cmd_id); + ten_string_set_formatted(ten_value_peek_string(&self->cmd_id), "%s", cmd_id); } ten_string_t *ten_raw_cmd_base_get_cmd_id(ten_cmd_base_t *self) { @@ -238,7 +240,7 @@ void ten_cmd_base_save_cmd_id_to_parent_cmd_id(ten_shared_ptr_t *self) { void ten_raw_cmd_base_set_seq_id(ten_cmd_base_t *self, const char *seq_id) { TEN_ASSERT(self && ten_raw_cmd_base_check_integrity(self) && seq_id, "Should not happen."); - ten_string_init_formatted(ten_value_peek_string(&self->seq_id), "%s", seq_id); + ten_string_set_formatted(ten_value_peek_string(&self->seq_id), "%s", seq_id); } bool ten_raw_cmd_base_get_field_from_json(ten_msg_t *self, ten_json_t *json, diff --git a/core/src/ten_runtime/msg/cmd_base/cmd_result/cmd.c b/core/src/ten_runtime/msg/cmd_base/cmd_result/cmd.c index 088939da7..903113a81 100644 --- a/core/src/ten_runtime/msg/cmd_base/cmd_result/cmd.c +++ b/core/src/ten_runtime/msg/cmd_base/cmd_result/cmd.c @@ -64,6 +64,8 @@ void ten_raw_cmd_result_destroy(ten_cmd_result_t *self) { ten_raw_cmd_base_deinit(&self->cmd_base_hdr); ten_signature_set(&self->signature, 0); + ten_string_deinit(ten_value_peek_string(&self->original_cmd_name)); + TEN_FREE(self); } @@ -414,6 +416,7 @@ static void ten_raw_cmd_result_set_original_cmd_name( TEN_ASSERT(original_cmd_name && strlen(original_cmd_name), "Invalid argument."); + ten_string_deinit(ten_value_peek_string(&self->original_cmd_name)); ten_string_init_from_c_str(ten_value_peek_string(&self->original_cmd_name), original_cmd_name, strlen(original_cmd_name)); } diff --git a/core/src/ten_runtime/msg/cmd_base/field/cmd_id.c b/core/src/ten_runtime/msg/cmd_base/field/cmd_id.c index 48568171b..595d21146 100644 --- a/core/src/ten_runtime/msg/cmd_base/field/cmd_id.c +++ b/core/src/ten_runtime/msg/cmd_base/field/cmd_id.c @@ -18,7 +18,7 @@ void ten_cmd_base_copy_cmd_id(ten_msg_t *self, ten_msg_t *src, TEN_UNUSED ten_list_t *excluded_field_ids) { TEN_ASSERT(src && ten_raw_msg_check_integrity(src), "Should not happen."); - ten_string_init_formatted( + ten_string_set_formatted( ten_value_peek_string(&((ten_cmd_base_t *)self)->cmd_id), "%s", ten_value_peek_raw_str(&((ten_cmd_base_t *)src)->cmd_id)); } diff --git a/core/src/ten_runtime/msg/cmd_base/field/seq_id.c b/core/src/ten_runtime/msg/cmd_base/field/seq_id.c index 4e319a5f2..6354ba417 100644 --- a/core/src/ten_runtime/msg/cmd_base/field/seq_id.c +++ b/core/src/ten_runtime/msg/cmd_base/field/seq_id.c @@ -18,7 +18,7 @@ void ten_cmd_base_copy_seq_id(ten_msg_t *self, ten_msg_t *src, TEN_UNUSED ten_list_t *excluded_field_ids) { TEN_ASSERT(src && ten_raw_msg_check_integrity(src), "Should not happen."); - ten_string_init_formatted( + ten_string_set_formatted( ten_value_peek_string(&((ten_cmd_base_t *)self)->seq_id), "%s", ten_value_peek_raw_str(&((ten_cmd_base_t *)src)->seq_id)); } diff --git a/core/src/ten_runtime/msg/field/src.c b/core/src/ten_runtime/msg/field/src.c index 9991fcc64..578c6472f 100644 --- a/core/src/ten_runtime/msg/field/src.c +++ b/core/src/ten_runtime/msg/field/src.c @@ -15,7 +15,7 @@ void ten_raw_msg_src_copy(ten_msg_t *self, ten_msg_t *src, ten_list_t *excluded_field_ids) { TEN_ASSERT(src && ten_raw_msg_check_integrity(src), "Should not happen."); - ten_loc_init_from_loc(&self->src_loc, &src->src_loc); + ten_loc_set_from_loc(&self->src_loc, &src->src_loc); } bool ten_raw_msg_src_process(ten_msg_t *self, @@ -32,7 +32,7 @@ bool ten_raw_msg_src_process(ten_msg_t *self, bool rc = cb(self, &src_field, user_data, err); if (src_field.value_is_changed_after_process) { - ten_loc_init_from_value(&self->src_loc, src_field.field_value); + ten_loc_set_from_value(&self->src_loc, src_field.field_value); } ten_value_destroy(src_value); diff --git a/core/src/ten_runtime/msg/msg.c b/core/src/ten_runtime/msg/msg.c index 6c816040a..1f5d6fb3c 100644 --- a/core/src/ten_runtime/msg/msg.c +++ b/core/src/ten_runtime/msg/msg.c @@ -92,7 +92,7 @@ void ten_raw_msg_deinit(ten_msg_t *self) { void ten_raw_msg_set_src_to_loc(ten_msg_t *self, ten_loc_t *loc) { TEN_ASSERT(self && ten_raw_msg_check_integrity(self), "Should not happen."); - ten_loc_init_from_loc(&self->src_loc, loc); + ten_loc_set_from_loc(&self->src_loc, loc); } void ten_msg_set_src_to_loc(ten_shared_ptr_t *self, ten_loc_t *loc) { @@ -938,7 +938,7 @@ void ten_msg_correct_dest(ten_shared_ptr_t *msg, ten_engine_t *engine) { // 'correct' the real destination location from 'localhost' to the real // URI of the app. - ten_string_init_from_c_str(&dest_loc->app_uri, app_uri, strlen(app_uri)); + ten_string_set_from_c_str(&dest_loc->app_uri, app_uri, strlen(app_uri)); is_local_app = true; } diff --git a/core/src/ten_runtime/msg_conversion/msg_conversion/per_property/rule.c b/core/src/ten_runtime/msg_conversion/msg_conversion/per_property/rule.c index d401a9a5d..7898c7c96 100644 --- a/core/src/ten_runtime/msg_conversion/msg_conversion/per_property/rule.c +++ b/core/src/ten_runtime/msg_conversion/msg_conversion/per_property/rule.c @@ -221,7 +221,7 @@ ten_msg_conversion_per_property_rule_from_value(ten_value_t *value, ten_msg_conversion_per_property_rule_t *self = ten_msg_conversion_per_property_rule_create(); - ten_string_init_formatted( + ten_string_set_formatted( &self->property_path, "%s", ten_value_peek_raw_str(ten_value_object_peek(value, TEN_STR_PATH))); diff --git a/core/src/ten_runtime/msg_conversion/msg_conversion_context.c b/core/src/ten_runtime/msg_conversion/msg_conversion_context.c index 39240f7af..bd3aa31af 100644 --- a/core/src/ten_runtime/msg_conversion/msg_conversion_context.c +++ b/core/src/ten_runtime/msg_conversion/msg_conversion_context.c @@ -4,6 +4,8 @@ // Licensed under the Apache License, Version 2.0, with certain conditions. // Refer to the "LICENSE" file in the root directory for more information. // +#include "include_internal/ten_runtime/msg_conversion/msg_conversion_context.h" + #include "include_internal/ten_runtime/common/loc.h" #include "include_internal/ten_runtime/extension/extension.h" #include "include_internal/ten_runtime/extension/extension_info/extension_info.h" @@ -11,7 +13,6 @@ #include "include_internal/ten_runtime/msg_conversion/msg_and_its_result_conversion.h" #include "include_internal/ten_runtime/msg_conversion/msg_and_result_conversion.h" #include "include_internal/ten_runtime/msg_conversion/msg_conversion/base.h" -#include "include_internal/ten_runtime/msg_conversion/msg_conversion_context.h" #include "ten_runtime/common/errno.h" #include "ten_utils/container/list.h" #include "ten_utils/container/list_node.h" diff --git a/core/src/ten_runtime/path/path.c b/core/src/ten_runtime/path/path.c index 1de011ddd..568e6fb44 100644 --- a/core/src/ten_runtime/path/path.c +++ b/core/src/ten_runtime/path/path.c @@ -79,6 +79,8 @@ void ten_path_deinit(ten_path_t *self) { // the thread safety here. TEN_ASSERT(ten_path_check_integrity(self, false), "Should not happen."); + ten_string_deinit(&self->cmd_name); + ten_string_deinit(&self->cmd_id); ten_string_deinit(&self->original_cmd_id); diff --git a/core/src/ten_runtime/path/path_table.c b/core/src/ten_runtime/path/path_table.c index 979c2d855..8d781261c 100644 --- a/core/src/ten_runtime/path/path_table.c +++ b/core/src/ten_runtime/path/path_table.c @@ -248,6 +248,9 @@ ten_path_in_t *ten_path_table_add_in_path( ten_list_push_ptr_back(&self->in_paths, in_path, (ten_ptr_listnode_destroy_func_t)ten_path_in_destroy); + ten_loc_deinit(&src_loc); + ten_loc_deinit(&dest_loc); + return in_path; } @@ -297,6 +300,9 @@ ten_path_out_t *ten_path_table_add_out_path(ten_path_table_t *self, ten_list_push_ptr_back(&self->out_paths, out_path, (ten_ptr_listnode_destroy_func_t)ten_path_out_destroy); + ten_loc_deinit(&src_loc); + ten_loc_deinit(&dest_loc); + return out_path; } diff --git a/core/src/ten_runtime/timer/timer.c b/core/src/ten_runtime/timer/timer.c index 2c1b3d4d8..82e4d2667 100644 --- a/core/src/ten_runtime/timer/timer.c +++ b/core/src/ten_runtime/timer/timer.c @@ -222,7 +222,7 @@ ten_timer_t *ten_timer_create_with_cmd(ten_shared_ptr_t *cmd, self->id = ten_cmd_timer_get_timer_id(cmd); self->timeout_in_us = ten_cmd_timer_get_timeout_in_us(cmd); self->requested_times = ten_cmd_timer_get_times(cmd); - ten_loc_init_from_loc(&self->src_loc, ten_msg_get_src_loc(cmd)); + ten_loc_set_from_loc(&self->src_loc, ten_msg_get_src_loc(cmd)); return self; } @@ -237,6 +237,7 @@ void ten_timer_destroy(ten_timer_t *self) { ten_sanitizer_thread_check_deinit(&self->thread_check); ten_signature_set(&self->signature, 0); + ten_loc_deinit(&self->src_loc); TEN_FREE(self); } diff --git a/core/src/ten_utils/io/general/socket.c b/core/src/ten_utils/io/general/socket.c index 120410c33..ba5c5c3b0 100644 --- a/core/src/ten_utils/io/general/socket.c +++ b/core/src/ten_utils/io/general/socket.c @@ -21,8 +21,8 @@ #include #endif -#include "ten_utils/macro/check.h" #include "ten_utils/lib/alloc.h" +#include "ten_utils/macro/check.h" ten_socket_addr_t *ten_socket_addr_create(const char *address, uint16_t port) { ten_socket_addr_t *self = @@ -114,7 +114,7 @@ void ten_socket_get_info(ten_socket_t *self, ten_string_t *ip, uint16_t *port) { getsockname(self->fd, (struct sockaddr *)&socket_info, &socket_info_size); char ip_buf[INET_ADDRSTRLEN + 1]; - ten_string_init_formatted( + ten_string_set_formatted( ip, "%s", inet_ntop(AF_INET, &socket_info.sin_addr, ip_buf, sizeof(ip_buf))); diff --git a/core/src/ten_utils/lib/sys/general/string.c b/core/src/ten_utils/lib/sys/general/string.c index 8f4bd5e40..a07545cb1 100644 --- a/core/src/ten_utils/lib/sys/general/string.c +++ b/core/src/ten_utils/lib/sys/general/string.c @@ -22,6 +22,11 @@ #define strtok_r strtok_s #endif +bool ten_string_buf_needs_free(ten_string_t *self) { + TEN_ASSERT(self, "Invalid argument."); + return self->buf != NULL && self->buf != self->pre_buf; +} + ten_string_t *ten_string_create(void) { ten_string_t *self = (ten_string_t *)TEN_MALLOC(sizeof(ten_string_t)); TEN_ASSERT(self, "Failed to allocate memory."); @@ -110,6 +115,16 @@ void ten_string_destroy(ten_string_t *self) { void ten_string_init(ten_string_t *self) { TEN_ASSERT(self, "Invalid argument."); + TEN_ASSERT(ten_signature_get(&self->signature) != TEN_STRING_SIGNATURE, + "Should not happen."); + + // Check if the signature indicates that the structure is already initialized. + if (ten_signature_get(&self->signature) == TEN_STRING_SIGNATURE) { + // Free any allocated memory. + if (self->buf && self->buf != self->pre_buf) { + TEN_FREE(self->buf); + } + } ten_signature_set(&self->signature, (ten_signature_t)TEN_STRING_SIGNATURE); @@ -127,11 +142,24 @@ void ten_string_init_from_va_list(ten_string_t *self, const char *fmt, ten_string_append_from_va_list(self, fmt, ap); } +void ten_string_copy_construct(ten_string_t *self, ten_string_t *other) { + TEN_ASSERT(self && !ten_string_buf_needs_free(self), "Invalid argument."); + TEN_ASSERT(other && ten_string_check_integrity(other) && + ten_string_get_raw_str(other), + "Invalid argument."); + + ten_string_init_formatted(self, "%s", ten_string_get_raw_str(other)); +} + void ten_string_copy(ten_string_t *self, ten_string_t *other) { - TEN_ASSERT(self && other && ten_string_check_integrity(other) && + TEN_ASSERT(self, "Invalid argument."); + TEN_ASSERT(other && ten_string_check_integrity(other) && ten_string_get_raw_str(other), "Invalid argument."); + // Deinitialize self to free any existing content. + ten_string_deinit(self); + ten_string_init_formatted(self, "%s", ten_string_get_raw_str(other)); } @@ -144,17 +172,22 @@ void ten_string_init_formatted(ten_string_t *self, const char *fmt, ...) { va_end(ap); } -void ten_string_init_from_c_str(ten_string_t *self, const char *other, +void ten_string_init_from_c_str(ten_string_t *self, const char *str, size_t size) { - TEN_ASSERT(self && other, "Invalid argument."); + TEN_ASSERT(self && str, "Invalid argument."); + TEN_ASSERT(size, "Invalid argument."); ten_string_init(self); + ten_string_set_formatted(self, "%.*s", size, str); +} - if (size == 0) { - size = strlen(other); - } +void ten_string_set_from_c_str(ten_string_t *self, const char *str, + size_t size) { + TEN_ASSERT(self && ten_string_check_integrity(self) && str, + "Invalid argument."); + TEN_ASSERT(size, "Invalid argument."); - ten_string_set_formatted(self, "%.*s", size, other); + ten_string_set_formatted(self, "%.*s", size, str); } void ten_string_set_formatted(ten_string_t *self, const char *fmt, ...) { @@ -217,11 +250,9 @@ void ten_string_append_formatted(ten_string_t *self, const char *fmt, ...) { va_end(ap); } -void ten_string_deinit(ten_string_t *self) { +void ten_string_reset(ten_string_t *self) { TEN_ASSERT(self && ten_string_check_integrity(self), "Invalid argument."); - ten_signature_set(&self->signature, 0); - if (self->buf && self->buf != self->pre_buf) { TEN_FREE(self->buf); self->buf = self->pre_buf; @@ -230,6 +261,13 @@ void ten_string_deinit(ten_string_t *self) { self->first_unused_idx = 0; } +void ten_string_deinit(ten_string_t *self) { + TEN_ASSERT(self && ten_string_check_integrity(self), "Invalid argument."); + + ten_string_reset(self); + ten_signature_set(&self->signature, 0); +} + void ten_string_clear(ten_string_t *self) { TEN_ASSERT(self && ten_string_check_integrity(self), "Invalid argument."); self->first_unused_idx = 0; diff --git a/core/src/ten_utils/value/value.c b/core/src/ten_utils/value/value.c index 95af66bdc..d03214503 100644 --- a/core/src/ten_utils/value/value.c +++ b/core/src/ten_utils/value/value.c @@ -25,6 +25,7 @@ #include "ten_utils/macro/mark.h" #include "ten_utils/macro/memory.h" #include "ten_utils/value/type.h" +#include "ten_utils/value/value_is.h" #include "ten_utils/value/value_kv.h" bool ten_value_check_integrity(ten_value_t *self) { @@ -50,6 +51,8 @@ static bool ten_value_copy_int8(ten_value_t *dest, ten_value_t *src, static void ten_value_init(ten_value_t *self) { TEN_ASSERT(self, "Invalid argument."); + // Initialize all memory within `value` to 0, so that the type within it (such + // as `ten_string_t`) recognizes it as being in an uninitialized state. memset(self, 0, sizeof(ten_value_t)); ten_signature_set(&self->signature, (ten_signature_t)TEN_VALUE_SIGNATURE); @@ -331,6 +334,16 @@ bool ten_value_init_bool(ten_value_t *self, bool value) { return true; } +static bool ten_value_copy_construct_string(ten_value_t *dest, ten_value_t *src, + TEN_UNUSED ten_error_t *err) { + TEN_ASSERT(dest && src, "Invalid argument."); + TEN_ASSERT(src->type == TEN_TYPE_STRING, "Invalid argument."); + + ten_string_copy_construct(&dest->content.string, &src->content.string); + + return true; +} + static bool ten_value_copy_string(ten_value_t *dest, ten_value_t *src, TEN_UNUSED ten_error_t *err) { TEN_ASSERT(dest && src, "Invalid argument."); @@ -357,10 +370,10 @@ bool ten_value_init_string(ten_value_t *self) { ten_value_init(self); self->type = TEN_TYPE_STRING; - ten_string_init(&self->content.string); + ten_string_init(&self->content.string); self->construct = NULL; - self->copy = ten_value_copy_string; + self->copy = ten_value_copy_construct_string; self->destruct = ten_value_destruct_string; return true; @@ -383,7 +396,7 @@ bool ten_value_init_string_with_size(ten_value_t *self, const char *str, TEN_ASSERT(str, "Invalid argument."); ten_value_init_string(self); - ten_string_init_formatted(&self->content.string, "%.*s", len, str); + ten_string_set_formatted(&self->content.string, "%.*s", len, str); return true; } @@ -773,6 +786,27 @@ ten_value_t *ten_value_create_buf_with_move(ten_buf_t buf) { return self; } +bool ten_value_copy_construct(ten_value_t *src, ten_value_t *dest) { + TEN_ASSERT(src && ten_value_check_integrity(src), "Invalid argument."); + TEN_ASSERT(dest && ten_value_check_integrity(dest), "Invalid argument."); + + dest->type = src->type; + + ten_value_construct_func_t construct = src->construct; + ten_value_destruct_func_t destruct = src->destruct; + ten_value_copy_func_t copy = src->copy; + + if (src->copy) { + src->copy(dest, src, NULL); + } + + dest->construct = construct; + dest->destruct = destruct; + dest->copy = copy; + + return true; +} + bool ten_value_copy(ten_value_t *src, ten_value_t *dest) { TEN_ASSERT(src && ten_value_check_integrity(src), "Invalid argument."); TEN_ASSERT(dest && ten_value_check_integrity(dest), "Invalid argument."); diff --git a/core/src/ten_utils/value/value_path.c b/core/src/ten_utils/value/value_path.c index 85bfa95e0..deee2f7c5 100644 --- a/core/src/ten_utils/value/value_path.c +++ b/core/src/ten_utils/value/value_path.c @@ -8,7 +8,6 @@ #include -#include "ten_utils/macro/check.h" #include "include_internal/ten_utils/value/constant_str.h" #include "ten_runtime/common/errno.h" #include "ten_utils/container/list.h" @@ -16,6 +15,7 @@ #include "ten_utils/container/list_node_ptr.h" #include "ten_utils/lib/alloc.h" #include "ten_utils/lib/string.h" +#include "ten_utils/macro/check.h" #include "ten_utils/macro/mark.h" #include "ten_utils/value/type.h" #include "ten_utils/value/value.h" @@ -58,6 +58,10 @@ static ten_value_path_item_t *ten_value_path_item_create(void) { (ten_value_path_item_t *)TEN_MALLOC(sizeof(ten_value_path_item_t)); TEN_ASSERT(item, "Failed to allocate memory."); + // Initialize all memory within `item` to 0, so that the type within it (such + // as `ten_string_t`) recognizes it as being in an uninitialized state. + memset(item, 0, sizeof(ten_value_path_item_t)); + item->type = TEN_VALUE_PATH_ITEM_TYPE_INVALID; return item; @@ -84,7 +88,7 @@ static ten_value_path_item_t *ten_value_path_parse_between_bracket( if (is_first) { item->type = TEN_VALUE_PATH_ITEM_TYPE_OBJECT_ITEM; - ten_string_copy(&item->obj_item_str, content); + ten_string_copy_construct(&item->obj_item_str, content); } else { if (!ten_c_string_is_equal( ten_string_get_raw_str(content) + ten_string_len(content) - 1, diff --git a/core/src/ten_utils/value/value_set.c b/core/src/ten_utils/value/value_set.c index 774cb21bc..d912b1b2f 100644 --- a/core/src/ten_utils/value/value_set.c +++ b/core/src/ten_utils/value/value_set.c @@ -111,12 +111,22 @@ bool ten_value_set_float64(ten_value_t *self, double value) { return true; } -bool ten_value_set_string(ten_value_t *self, const char *value) { +bool ten_value_set_string(ten_value_t *self, const char *str) { TEN_ASSERT(self, "Invalid argument."); - TEN_ASSERT(self->type == TEN_TYPE_STRING, "Invalid argument."); + TEN_ASSERT(ten_value_is_string(self), "Invalid argument."); - ten_string_init_formatted(&self->content.string, "%.*s", strlen(value), - value); + ten_string_set_formatted(&self->content.string, "%.*s", strlen(str), str); + + return true; +} + +bool ten_value_set_string_with_size(ten_value_t *self, const char *str, + size_t len) { + TEN_ASSERT(self && ten_value_check_integrity(self), "Invalid argument."); + TEN_ASSERT(ten_value_is_string(self), "Invalid argument."); + TEN_ASSERT(str, "Invalid argument."); + + ten_string_set_formatted(&self->content.string, "%.*s", len, str); return true; } diff --git a/core/src/ten_utils/value/value_string.c b/core/src/ten_utils/value/value_string.c index 27bcea10e..a1d8932fa 100644 --- a/core/src/ten_utils/value/value_string.c +++ b/core/src/ten_utils/value/value_string.c @@ -19,6 +19,7 @@ #include "ten_utils/macro/check.h" #include "ten_utils/value/type.h" #include "ten_utils/value/value.h" +#include "ten_utils/value/value_get.h" #include "ten_utils/value/value_is.h" #include "ten_utils/value/value_kv.h" @@ -300,3 +301,10 @@ ten_value_t *ten_value_from_type_and_string(TEN_TYPE type, const char *str, return result; } + +bool ten_value_string_buf_needs_free(ten_value_t *self) { + TEN_ASSERT(self && ten_value_check_integrity(self), "Invalid argument."); + TEN_ASSERT(ten_value_is_string(self), "Invalid argument."); + + return ten_string_buf_needs_free(ten_value_peek_string(self)); +} diff --git a/tests/ten_runtime/smoke/extension_test/timer/timer_one_shot.cc b/tests/ten_runtime/smoke/extension_test/timer/timer_one_shot.cc index d822ff668..0a818bfc0 100644 --- a/tests/ten_runtime/smoke/extension_test/timer/timer_one_shot.cc +++ b/tests/ten_runtime/smoke/extension_test/timer/timer_one_shot.cc @@ -84,7 +84,7 @@ class test_app : public ten::app_t { // clang-format off R"({ "_ten": { - "uri": "msgpack://127.0.0.1:8001/", + "uri": "msgpack://127.0.0.1:8010/", "log_level": 2 } })" @@ -114,7 +114,7 @@ TEST(ExtensionTest, TimerOneShot) { ten_thread_create("app thread", test_app_thread_main, nullptr); // Create a client and connect to the app. - auto *client = new ten::msgpack_tcp_client_t("msgpack://127.0.0.1:8001/"); + auto *client = new ten::msgpack_tcp_client_t("msgpack://127.0.0.1:8010/"); // Send graph. nlohmann::json resp = client->send_json_and_recv_resp_in_json( @@ -126,7 +126,7 @@ TEST(ExtensionTest, TimerOneShot) { "type": "extension", "name": "test_extension", "addon": "timer_one_shot__extension", - "app": "msgpack://127.0.0.1:8001/", + "app": "msgpack://127.0.0.1:8010/", "extension_group": "timer_one_shot__extension_group" }] } @@ -140,7 +140,7 @@ TEST(ExtensionTest, TimerOneShot) { "name": "hello_world", "seq_id": "137", "dest":[{ - "app": "msgpack://127.0.0.1:8001/", + "app": "msgpack://127.0.0.1:8010/", "extension_group": "timer_one_shot__extension_group", "extension": "test_extension" }]