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;
}
}
call_rcu_unlock(&call_rcu_mutex);
if ((ret = set_cpu_call_rcu_data(i, crdp)) != 0) {
- /* FIXME: Leaks crdp for now. */
- return ret; /* Can happen on race. */
+ call_rcu_data_free(crdp);
+
+ /* it has been created by other thread */
+ if (ret == -EEXIST)
+ continue;
+
+ return ret;
}
}
return 0;
_CMM_STORE_SHARED(crdp->cbs.head, NULL);
cbs_tail = (struct cds_wfq_node **)
uatomic_xchg(&crdp->cbs.tail, &crdp->cbs.head);
+ /* Create default call rcu data if need be */
+ (void) get_default_call_rcu_data();
cbs_endprev = (struct cds_wfq_node **)
uatomic_xchg(&default_call_rcu_data, cbs_tail);
*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);
}
/*