Return -EEXIST when the old cpu call_rcu_data has not been removed
[urcu.git] / urcu-call-rcu-impl.h
index 6cb08be5731299c0d3334face6296faf9a98d7e7..ae93468d8beb4e9fb9167a4dcc5b462892f3d9a2 100644 (file)
@@ -396,12 +396,21 @@ int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
                errno = EINVAL;
                return -EINVAL;
        }
-       call_rcu_unlock(&call_rcu_mutex);
+
        if (per_cpu_call_rcu_data == NULL) {
+               call_rcu_unlock(&call_rcu_mutex);
                errno = ENOMEM;
                return -ENOMEM;
        }
+
+       if (per_cpu_call_rcu_data[cpu] != NULL && crdp != NULL) {
+               call_rcu_unlock(&call_rcu_mutex);
+               errno = EEXIST;
+               return -EEXIST;
+       }
+
        per_cpu_call_rcu_data[cpu] = crdp;
+       call_rcu_unlock(&call_rcu_mutex);
        return 0;
 }
 
@@ -600,9 +609,11 @@ void call_rcu_data_free(struct call_rcu_data *crdp)
                *cbs_endprev = cbs;
                uatomic_add(&default_call_rcu_data->qlen,
                            uatomic_read(&crdp->qlen));
-               cds_list_del(&crdp->list);
-               free(crdp);
+               wake_call_rcu_thread(default_call_rcu_data);
        }
+
+       cds_list_del(&crdp->list);
+       free(crdp);
 }
 
 /*
This page took 0.022293 seconds and 4 git commands to generate.