Skip to content

Commit

Permalink
chore: update some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Oct 28, 2024
1 parent c328380 commit 895252a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 3 additions & 6 deletions c_src/quicer_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 7 additions & 9 deletions c_src/quicer_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions c_src/quicer_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 895252a

Please sign in to comment.