From: Lai Jiangshan Date: Thu, 15 Sep 2011 15:22:03 +0000 (-0400) Subject: Return -EEXIST when the old cpu call_rcu_data has not been removed X-Git-Tag: v0.6.5~14 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=53a55535da7db6ac6a2f37107baed9130c049333;p=userspace-rcu.git Return -EEXIST when the old cpu call_rcu_data has not been removed To make it matches the comments. It is the caller's responsibility to use set_cpu_call_rcu_data(cpu, NULL) to remove the CPU's call_rcu_data structure and dispose it. Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-call-rcu-impl.h b/urcu-call-rcu-impl.h index c822646..ae93468 100644 --- a/urcu-call-rcu-impl.h +++ b/urcu-call-rcu-impl.h @@ -396,11 +396,19 @@ int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp) errno = EINVAL; return -EINVAL; } + 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;