api: add heap alloc to vpp stats
The Python VPP Stats module also used the VPP heap.
Fix so it now explicitly allocates a heap.
Fixes: f68fccfe7e
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I0bd4ae64d6c89cdf634d8d9a91c23ab38017c5cc
Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
@@ -79,6 +79,9 @@ u16 read_timeout = 0;
|
||||
bool rx_is_running = false;
|
||||
bool timeout_thread_cancelled = false;
|
||||
|
||||
/* Only ever allocate one heap */
|
||||
bool mem_initialized = false;
|
||||
|
||||
static void
|
||||
init (void)
|
||||
{
|
||||
@@ -564,8 +567,11 @@ vac_set_error_handler (vac_error_callback_t cb)
|
||||
void
|
||||
vac_mem_init (size_t size)
|
||||
{
|
||||
if (mem_initialized)
|
||||
return;
|
||||
if (size == 0)
|
||||
clib_mem_init (0, 1 << 30); // default
|
||||
else
|
||||
clib_mem_init (0, size);
|
||||
mem_initialized = true;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ char *stat_segment_index_to_name_r (uint32_t index, stat_client_main_t * sm);
|
||||
uint64_t stat_segment_version(void);
|
||||
uint64_t stat_segment_version_r(stat_client_main_t *sm);
|
||||
void free(void *ptr);
|
||||
void vac_mem_init (size_t size);
|
||||
""") # noqa: E501
|
||||
|
||||
|
||||
@@ -203,6 +204,7 @@ class VPPStats(object):
|
||||
except Exception:
|
||||
raise VPPStatsClientLoadError("Could not open: %s" %
|
||||
VPPStats.sharedlib_name)
|
||||
self.api.vac_mem_init(0)
|
||||
|
||||
def connect(self):
|
||||
self.client = self.api.stat_client_get()
|
||||
|
||||
@@ -68,7 +68,7 @@ class VppTransport(object):
|
||||
global vpp_object
|
||||
vpp_object = parent
|
||||
|
||||
vpp_api.vac_mem_init(0);
|
||||
vpp_api.vac_mem_init(0)
|
||||
|
||||
# Register error handler
|
||||
vpp_api.vac_set_error_handler(vac_error_handler)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
import time
|
||||
import psutil
|
||||
from vpp_papi.vpp_stats import VPPStats
|
||||
|
||||
|
||||
Reference in New Issue
Block a user