x86: drop extra semi-colon in caa_cpu_relax
[urcu.git] / urcu-bp.c
index 836ef92fe1f8ba92335ab9b8a3047e51f520d190..7a591a20da3ac8a58adc8c1ca1c0ffbf982350fe 100644 (file)
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -79,8 +79,8 @@ void *mremap_wrapper(void *old_address, size_t old_size,
 }
 #endif
 
-/* Sleep delay in us */
-#define RCU_SLEEP_DELAY                1000
+/* Sleep delay in ms */
+#define RCU_SLEEP_DELAY_MS     10
 #define INIT_NR_THREADS                8
 #define ARENA_INIT_ALLOC               \
        sizeof(struct registry_chunk)   \
@@ -97,7 +97,7 @@ int rcu_bp_refcount;
 static
 void __attribute__((constructor)) rcu_bp_init(void);
 static
-void __attribute__((destructor)) rcu_bp_exit(void);
+void __attribute__((destructor)) _rcu_bp_exit(void);
 
 static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER;
 
@@ -169,7 +169,7 @@ static void wait_for_readers(struct cds_list_head *input_readers,
                        struct cds_list_head *cur_snap_readers,
                        struct cds_list_head *qsreaders)
 {
-       int wait_loops = 0;
+       unsigned int wait_loops = 0;
        struct rcu_reader *index, *tmp;
 
        /*
@@ -178,7 +178,9 @@ static void wait_for_readers(struct cds_list_head *input_readers,
         * rcu_gp.ctr value.
         */
        for (;;) {
-               wait_loops++;
+               if (wait_loops < RCU_QS_ACTIVE_ATTEMPTS)
+                       wait_loops++;
+
                cds_list_for_each_entry_safe(index, tmp, input_readers, node) {
                        switch (rcu_reader_state(&index->ctr)) {
                        case RCU_READER_ACTIVE_CURRENT:
@@ -205,8 +207,8 @@ static void wait_for_readers(struct cds_list_head *input_readers,
                if (cds_list_empty(input_readers)) {
                        break;
                } else {
-                       if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS)
-                               usleep(RCU_SLEEP_DELAY);
+                       if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS)
+                               (void) poll(NULL, 0, RCU_SLEEP_DELAY_MS);
                        else
                                caa_cpu_relax();
                }
@@ -517,7 +519,7 @@ void rcu_bp_unregister(struct rcu_reader *rcu_reader_reg)
        ret = pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
        if (ret)
                abort();
-       rcu_bp_exit();
+       _rcu_bp_exit();
 }
 
 /*
@@ -547,7 +549,7 @@ void rcu_bp_init(void)
 }
 
 static
-void rcu_bp_exit(void)
+void _rcu_bp_exit(void)
 {
        mutex_lock(&init_lock);
        if (!--rcu_bp_refcount) {
@@ -566,6 +568,15 @@ void rcu_bp_exit(void)
        mutex_unlock(&init_lock);
 }
 
+/*
+ * Keep ABI compability within stable versions. This has never been
+ * exposed through a header, but needs to stay in the .so until the
+ * soname is bumped.
+ */
+void rcu_bp_exit(void)
+{
+}
+
 /*
  * Holding the rcu_gp_lock across fork will make sure we fork() don't race with
  * a concurrent thread executing with this same lock held. This ensures that the
This page took 0.0249 seconds and 4 git commands to generate.