X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu-qsbr.c;h=ccecab4e7b02b63d80f6c87085486dee0a5452f5;hb=1a80f35636b70a4f40e0568fbef31b3764035f6f;hp=c0f055441930ab8718cd4d4347325bd6671dc2fc;hpb=d1238495fdaf1c85447690231bf5d1838b83bf88;p=urcu.git diff --git a/urcu-qsbr.c b/urcu-qsbr.c index c0f0554..ccecab4 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -32,6 +32,7 @@ #include #include +#define BUILD_QSBR_LIB #include "urcu-qsbr-static.h" /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ #include "urcu-qsbr.h" @@ -114,9 +115,6 @@ static void wait_for_quiescent_state(void) { struct reader_registry *index; - if (rcu_reader_qs_gp & 1) - rcu_reader_qs_gp = urcu_gp_ctr + 1; - if (!registry) return; /* @@ -148,12 +146,27 @@ static void wait_for_quiescent_state(void) void synchronize_rcu(void) { + int was_online; + + was_online = rcu_reader_qs_gp & 1; + + /* + * Mark the writer thread offline to make sure we don't wait for + * our own quiescent state. This allows using synchronize_rcu() in + * threads registered as readers. + */ + if (was_online) + _rcu_thread_offline(); + internal_urcu_lock(); force_mb_all_threads(); urcu_gp_ctr += 2; wait_for_quiescent_state(); force_mb_all_threads(); internal_urcu_unlock(); + + if (was_online) + _rcu_thread_online(); } /*