Skip to content

Commit

Permalink
fix: refine codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxilin committed Nov 5, 2024
1 parent 2306c9d commit 4373522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion core/src/ten_runtime/protocol/asynced/protocol_asynced.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ static void ten_protocol_asynced_on_client_accepted(void *self, void *info_) {
ten_app_t *app = listening_base_protocol->attached_target.app;
TEN_ASSERT(app && ten_app_check_integrity(app, true), "Should not happen.");

ten_error_t err;
ten_error_init(&err);

// We can _not_ know whether the protocol role is
// 'TEN_PROTOCOL_ROLE_IN_INTERNAL' or 'TEN_PROTOCOL_ROLE_IN_EXTERNAL'
// until the message received from the protocol is processed. Refer to
Expand All @@ -475,7 +478,10 @@ static void ten_protocol_asynced_on_client_accepted(void *self, void *info_) {
app->ten_env, ten_string_get_raw_str(&addon_host->name),
ten_string_get_raw_str(&addon_host->name), TEN_PROTOCOL_ROLE_IN_DEFAULT,
ten_app_thread_on_client_protocol_created, info, NULL);
TEN_ASSERT(rc, "Should not happen.");
TEN_ASSERT(rc, "Failed to create protocol, err: %s",
ten_error_errmsg(&err));

ten_error_deinit(&err);
}

// The task is completed, so delete a reference to the 'protocol' to reflect
Expand Down
10 changes: 8 additions & 2 deletions core/src/ten_runtime/protocol/integrated/protocol_integrated.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ten_utils/io/runloop.h"
#include "ten_utils/io/stream.h"
#include "ten_utils/lib/alloc.h"
#include "ten_utils/lib/error.h"
#include "ten_utils/lib/mutex.h"
#include "ten_utils/lib/ref.h"
#include "ten_utils/lib/smart_ptr.h"
Expand Down Expand Up @@ -337,6 +338,9 @@ static void ten_protocol_integrated_on_client_accepted(
ten_app_t *app = listening_base_protocol->attached_target.app;
TEN_ASSERT(app && ten_app_check_integrity(app, true), "Should not happen.");

ten_error_t err;
ten_error_init(&err);

// We can _not_ know whether the protocol role is
// 'TEN_PROTOCOL_ROLE_IN_INTERNAL' or 'TEN_PROTOCOL_ROLE_IN_EXTERNAL' until
// the message received from the protocol is processed. Refer to
Expand All @@ -347,8 +351,10 @@ static void ten_protocol_integrated_on_client_accepted(
ten_string_get_raw_str(&listening_base_protocol->addon_host->name),
ten_string_get_raw_str(&listening_base_protocol->addon_host->name),
TEN_PROTOCOL_ROLE_IN_DEFAULT, ten_app_thread_on_client_protocol_created,
stream, NULL);
TEN_ASSERT(rc, "Should not happen.");
stream, &err);
TEN_ASSERT(rc, "Failed to create protocol, err: %s", ten_error_errmsg(&err));

ten_error_deinit(&err);
}

static void ten_protocol_integrated_listen(ten_protocol_integrated_t *self,
Expand Down

0 comments on commit 4373522

Please sign in to comment.