From 895252ad831e808aaecc8c0d441a13cb19e4809c Mon Sep 17 00:00:00 2001 From: William Yang Date: Mon, 28 Oct 2024 11:21:14 +0100 Subject: [PATCH] chore: update some comments --- c_src/quicer_connection.c | 9 +++------ c_src/quicer_stream.c | 16 +++++++--------- c_src/quicer_tp.c | 2 ++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/c_src/quicer_connection.c b/c_src/quicer_connection.c index cb4276ed..18dd0de7 100644 --- a/c_src/quicer_connection.c +++ b/c_src/quicer_connection.c @@ -1413,9 +1413,7 @@ handle_connection_event_peer_stream_started(QuicerConnCTX *c_ctx, { if (is_orphan) { - // Connection owner is dead - // we should not destroy the acceptor, because it is owned by the - return selected_owner_unreachable(s_ctx); // cheat + return selected_owner_unreachable(s_ctx); } else { @@ -1426,6 +1424,7 @@ handle_connection_event_peer_stream_started(QuicerConnCTX *c_ctx, AcceptorDestroy(acc); // Set is_orphan to true, connection owner takeover props_value[1] = ATOM_TRUE; + acc = AcceptorAlloc(); CxPlatCopyMemory(acc, c_ctx->owner, sizeof(ACCEPTOR)); s_ctx->owner = acc; @@ -1852,9 +1851,7 @@ selected_owner_unreachable(QuicerStreamCTX *s_ctx) { // // s_ctx ownership transfer failed - // We must release ctx twice, here and in `destroy_s_ctx`. - // AND - // no callback from msquic + // There is no shared ownership, we must destroy the s_ctx here // s_ctx->is_closed = TRUE; enif_clear_env(s_ctx->env); diff --git a/c_src/quicer_stream.c b/c_src/quicer_stream.c index ae7d8746..9b675c8f 100644 --- a/c_src/quicer_stream.c +++ b/c_src/quicer_stream.c @@ -958,15 +958,13 @@ handle_stream_event_recv(HQUIC Stream, { // Owner is waiting for data // notify owner to trigger async recv // - if (!enif_send( - NULL, - &(s_ctx->owner->Pid), - NULL, - make_event(env, - ATOM_QUIC_STATUS_CONTINUE, - // @TODO eHandle is in env, no need to copy? - enif_make_copy(env, s_ctx->eHandle), - ATOM_UNDEFINED))) + if (!enif_send(NULL, + &(s_ctx->owner->Pid), + NULL, + make_event(env, + ATOM_QUIC_STATUS_CONTINUE, + enif_make_copy(env, s_ctx->eHandle), + ATOM_UNDEFINED))) { // App down, shutdown stream MsQuic->StreamShutdown(Stream, diff --git a/c_src/quicer_tp.c b/c_src/quicer_tp.c index 0824031d..2323525e 100644 --- a/c_src/quicer_tp.c +++ b/c_src/quicer_tp.c @@ -47,6 +47,8 @@ tp_snk(ErlNifEnv *env, { ErlNifPid *pid = &GLOBAL_SNAB_KC_PID; + // avoid polluting the context env, + // use tmp env for message passing, env = enif_alloc_env(); ERL_NIF_TERM snk_event;