vapi: fix vapi_ctx_alloc

clib_time_init() may use clib main heap when it needs to parse /proc
or /sys. Make sure the main heap is initialized early.

Type: fix

Change-Id: I891504f3455b97c06da25e4833a8fb6941eb428a
Signed-off-by: Benoît Ganne <bganne@cisco.com>
This commit is contained in:
Benoît Ganne 2024-11-29 14:14:16 +01:00
parent 978d48b765
commit 709f40c29d

View File

@ -300,6 +300,10 @@ vapi_lookup_vapi_msg_id_t (vapi_ctx_t ctx, u16 vl_msg_id)
vapi_error_e
vapi_ctx_alloc (vapi_ctx_t * result)
{
if (!clib_mem_get_per_cpu_heap () && !clib_mem_init (0, 1024L * 1024 * 32))
{
return VAPI_ENOMEM;
}
vapi_ctx_t ctx = calloc (1, sizeof (struct vapi_ctx_s));
if (!ctx)
{
@ -968,11 +972,6 @@ vapi_connect_ex (vapi_ctx_t ctx, const char *name, const char *path,
return VAPI_EINVAL;
}
if (!clib_mem_get_per_cpu_heap () && !clib_mem_init (0, 1024L * 1024 * 32))
{
return VAPI_ENOMEM;
}
ctx->requests_size = max_outstanding_requests;
const size_t size = ctx->requests_size * sizeof (*ctx->requests);
void *tmp = realloc (ctx->requests, size);