Skip to content

Commit

Permalink
fix: do not delay the closure of global registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhuyan committed Sep 28, 2023
1 parent 4bd1381 commit 3bdfb2d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions c_src/quicer_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ deregistration(__unused_parm__ ErlNifEnv *env,
__unused_parm__ int argc,
__unused_parm__ const ERL_NIF_TERM argv[])
{
// @TODO error_code should be configurable
int error_code = 0;
if (!MsQuic)
{
Expand All @@ -96,6 +97,11 @@ deregistration(__unused_parm__ ErlNifEnv *env,
if (G_r_ctx && !G_r_ctx->is_released)
{
MsQuic->RegistrationShutdown(G_r_ctx->Registration, FALSE, error_code);
// Do not defer the closing the global registration
// to resource dealloc callback because a common scenario is to
// close the lib after close the global registration.
MsQuic->RegistrationClose(G_r_ctx->Registration);
G_r_ctx->Registration = NULL;
destroy_r_ctx(G_r_ctx);
G_r_ctx = NULL;
}
Expand Down

0 comments on commit 3bdfb2d

Please sign in to comment.