From f1f619dea1738609061134f6d52b8158710bc7b5 Mon Sep 17 00:00:00 2001 From: William Yang Date: Thu, 10 Oct 2024 08:35:27 +0200 Subject: [PATCH] fix: owner sig leak if owner crash --- .gitignore | 5 +++++ c_src/quicer_ctx.c | 19 +++++++++++++++++++ c_src/quicer_ctx.h | 2 ++ 3 files changed, 26 insertions(+) diff --git a/.gitignore b/.gitignore index 1105f506..6e13cc70 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ erl_crash.dump .concrete/DEV_MODE .DS_Store .cache +build # rebar 2.x .rebar @@ -23,6 +24,7 @@ rebar.lock priv/*.so priv/*lttng.* priv/*.dylib +priv/** # language server caches .ccls-cache/ @@ -36,3 +38,6 @@ compile_commands.json # downloaded code msquic/ _packages/ + +# test logs +asan_logs/ diff --git a/c_src/quicer_ctx.c b/c_src/quicer_ctx.c index 26d74a5b..68fc8c76 100644 --- a/c_src/quicer_ctx.c +++ b/c_src/quicer_ctx.c @@ -277,6 +277,7 @@ init_s_ctx() void deinit_s_ctx(QuicerStreamCTX *s_ctx) { + cleanup_owner_signals(s_ctx); enif_mutex_destroy(s_ctx->lock); enif_free_env(s_ctx->env); } @@ -409,3 +410,21 @@ cache_stream_id(QuicerStreamCTX *s_ctx) s_ctx->StreamID = UNSET_STREAMID; } } + +void +cleanup_owner_signals(QuicerStreamCTX *s_ctx) +{ + OWNER_SIGNAL *sig; + + if (!s_ctx->sig_queue) + { + return; + } + while ((sig = OwnerSignalDequeue(s_ctx->sig_queue))) + { + CxPlatFree(sig, QUICER_OWNER_SIGNAL); + } + + OwnerSignalQueueDestroy(s_ctx->sig_queue); + s_ctx->sig_queue = NULL; +} diff --git a/c_src/quicer_ctx.h b/c_src/quicer_ctx.h index 51a25135..45204b83 100644 --- a/c_src/quicer_ctx.h +++ b/c_src/quicer_ctx.h @@ -197,4 +197,6 @@ BOOLEAN get_reg_handle(QuicerRegistrationCTX *r_ctx); void cache_stream_id(QuicerStreamCTX *s_ctx); +void cleanup_owner_signals(QuicerStreamCTX *s_ctx); + #endif // __QUICER_CTX_H_