* rseq_mempool_attr_set_init: Set pool attribute structure memory init functions.
*
* The @init_func callback used to initialized memory after allocation
- * for the pool.
+ * for the pool. The @init_func callback must return 0 on success, -1 on
+ * error with errno set. If @init_func returns failure, the allocation
+ * of the pool memory fails, which either causes the pool creation to
+ * fail or memory allocation to fail (for extensible memory pools).
*
* The @init_priv argument is a private data pointer passed to the
* @init_func callback.
* Returns 0 on success, -1 with errno=EINVAL if arguments are invalid.
*/
int rseq_mempool_attr_set_init(struct rseq_mempool_attr *attr,
- void (*init_func)(void *priv, void *addr, size_t len, int cpu),
+ int (*init_func)(void *priv, void *addr, size_t len, int cpu),
void *init_priv);
/*
void *mmap_priv;
bool init_set;
- void (*init_func)(void *priv, void *addr, size_t len, int cpu);
+ int (*init_func)(void *priv, void *addr, size_t len, int cpu);
void *init_priv;
bool robust_set;
int cpu;
for (cpu = 0; cpu < pool->attr.max_nr_cpus; cpu++) {
- pool->attr.init_func(pool->attr.init_priv,
- base + (pool->attr.stride * cpu),
- pool->attr.stride, cpu);
+ if (pool->attr.init_func(pool->attr.init_priv,
+ base + (pool->attr.stride * cpu),
+ pool->attr.stride, cpu)) {
+ goto error_alloc;
+ }
}
}
return range;
}
int rseq_mempool_attr_set_init(struct rseq_mempool_attr *attr,
- void (*init_func)(void *priv, void *addr, size_t len, int cpu),
+ int (*init_func)(void *priv, void *addr, size_t len, int cpu),
void *init_priv)
{
if (!attr) {