From 6613f89c62fd2a36c47f465578b0e86c1d05bae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 2 Jan 2023 13:26:41 +0100 Subject: [PATCH] Enhance the isc_loop unit to allow reference count tracking Use ISC_REFCOUNT_TRACE_{IMPL,DECL} to allow better isc_loop reference tracking - use `#define ISC_LOOP_TRACE 1` in to enable. --- lib/isc/include/isc/loop.h | 14 ++++++++++++++ lib/isc/loop.c | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/lib/isc/include/isc/loop.h b/lib/isc/include/isc/loop.h index 436392aa41..2706f6e6c8 100644 --- a/lib/isc/include/isc/loop.h +++ b/lib/isc/include/isc/loop.h @@ -22,6 +22,8 @@ typedef void (*isc_job_cb)(void *); +#undef ISC_LOOP_TRACE + ISC_LANG_BEGINDECLS void @@ -169,7 +171,19 @@ isc_loop_get(isc_loopmgr_t *loopmgr, uint32_t tid); *\li 'tid' is smaller than number of initialized loops */ +# + +#if ISC_LOOP_TRACE +#define isc_loop_ref(ptr) isc_loop__ref(ptr, __func__, __FILE__, __LINE__) +#define isc_loop_unref(ptr) isc_loop__unref(ptr, __func__, __FILE__, __LINE__) +#define isc_loop_attach(ptr, ptrp) \ + isc_loop__attach(ptr, ptrp, __func__, __FILE__, __LINE__) +#define isc_loop_detach(ptrp) \ + isc_loop__detach(ptrp, __func__, __FILE__, __LINE__) +ISC_REFCOUNT_TRACE_DECL(isc_loop); +#else ISC_REFCOUNT_DECL(isc_loop); +#endif /*%< * Reference counting functions for isc_loop */ diff --git a/lib/isc/loop.c b/lib/isc/loop.c index 0ab71a0543..3ec2c6ba52 100644 --- a/lib/isc/loop.c +++ b/lib/isc/loop.c @@ -330,7 +330,11 @@ loop_destroy(isc_loop_t *loop) { UV_RUNTIME_CHECK(uv_async_send, r); } +#if ISC_LOOP_TRACE +ISC_REFCOUNT_TRACE_IMPL(isc_loop, loop_destroy) +#else ISC_REFCOUNT_IMPL(isc_loop, loop_destroy); +#endif void isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp) {