update README
[urcu.git] / urcu-qsbr.c
index c0f055441930ab8718cd4d4347325bd6671dc2fc..d1f5d91846af8f8098eacab85a588d945ab9873f 100644 (file)
@@ -114,9 +114,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 +145,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();
 }
 
 /*
This page took 0.02257 seconds and 4 git commands to generate.