From: Mathieu Desnoyers Date: Mon, 13 Feb 2023 17:24:09 +0000 (-0500) Subject: Fix: urcu-bp: only teardown call-rcu worker in destructor X-Git-Tag: v0.12.5~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0c8eff157de6f7ab836ec87a340a517d49fdaca3;p=userspace-rcu.git Fix: urcu-bp: only teardown call-rcu worker in destructor Do not invoke urcu_call_rcu_exit() every time a reader thread unregisters from urcu-bp. This causes pthread join hangs observed on Cygwin. Signed-off-by: Mathieu Desnoyers Change-Id: I4e5c6e06df9966d65f2dcf01bb3281cbfcb05a5b --- diff --git a/src/urcu-bp.c b/src/urcu-bp.c index 35ac9db..1f9a038 100644 --- a/src/urcu-bp.c +++ b/src/urcu-bp.c @@ -120,7 +120,9 @@ enum membarrier_cmd { static void __attribute__((constructor)) _urcu_bp_init(void); static -void __attribute__((destructor)) urcu_bp_exit(void); +void urcu_bp_exit(void); +static +void __attribute__((destructor)) urcu_bp_exit_destructor(void); static void urcu_call_rcu_exit(void); #ifndef CONFIG_RCU_FORCE_SYS_MEMBARRIER @@ -663,8 +665,6 @@ void _urcu_bp_init(void) static void urcu_bp_exit(void) { - urcu_call_rcu_exit(); - mutex_lock(&init_lock); if (!--urcu_bp_refcount) { struct registry_chunk *chunk, *tmp; @@ -683,6 +683,13 @@ void urcu_bp_exit(void) mutex_unlock(&init_lock); } +static +void urcu_bp_exit_destructor(void) +{ + urcu_call_rcu_exit(); + urcu_bp_exit(); +} + /* * Holding the rcu_gp_lock and rcu_registry_lock across fork will make * sure we fork() don't race with a concurrent thread executing with