Skip to content

Commit

Permalink
fix: refcnt handle when switching controlling_process
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Feb 16, 2024
1 parent 0c1e627 commit f9b38e7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion c_src/quicer_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,16 +1383,26 @@ controlling_process(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])

if (enif_get_resource(env, argv[0], ctx_stream_t, (void **)&s_ctx))
{
if (!get_stream_handle(s_ctx))
{
return ERROR_TUPLE_2(ATOM_CLOSED);
}

enif_mutex_lock(s_ctx->lock);
res = stream_controlling_process(env, s_ctx, &caller, &new_owner);
enif_mutex_unlock(s_ctx->lock);
put_stream_handle(s_ctx);
}
else if (enif_get_resource(env, argv[0], ctx_connection_t, (void **)&c_ctx))
{

if (!get_conn_handle(c_ctx))
{
return ERROR_TUPLE_2(ATOM_CLOSED);
}
enif_mutex_lock(c_ctx->lock);
res = connection_controlling_process(env, c_ctx, &caller, &new_owner);
enif_mutex_unlock(c_ctx->lock);
put_conn_handle(c_ctx);
}
else
{
Expand Down

0 comments on commit f9b38e7

Please sign in to comment.