From 0cd861d195cf2f021f9e5c5c49b6f82dd9dfa993 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 13 Aug 2023 22:55:56 -0700 Subject: til_stream: assert when gc leaks in til_stream_free() It's expected that all mondule contexts will have been cleaned up by the final gc in til_stream_free(). If the gc returns a non-zero skipped count, it suggests there's a program bug leaking registered contexts. --- src/til_stream.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/til_stream.c b/src/til_stream.c index 0f35a17..247dbf3 100644 --- a/src/til_stream.c +++ b/src/til_stream.c @@ -131,10 +131,13 @@ int til_stream_active(til_stream_t *stream) til_stream_t * til_stream_free(til_stream_t *stream) { + unsigned leaked; + if (!stream) return NULL; - til_stream_gc_module_contexts(stream); + leaked = til_stream_gc_module_contexts(stream); + assert(!leaked); for (int i = 0; i < TIL_STREAM_PIPE_BUCKETS_COUNT; i++) { for (til_stream_pipe_t *p = stream->pipe_buckets[i], *p_next; p != NULL; p = p_next) { -- cgit v1.2.1