aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/client/client.c40
-rw-r--r--src/vpp-api/client/vppapiclient.h3
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_shmem.py5
3 files changed, 23 insertions, 25 deletions
diff --git a/src/vpp-api/client/client.c b/src/vpp-api/client/client.c
index 5dcca22694d..0d7b1dcafc8 100644
--- a/src/vpp-api/client/client.c
+++ b/src/vpp-api/client/client.c
@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -78,29 +79,6 @@ u16 read_timeout = 0;
bool rx_is_running = false;
bool timeout_thread_cancelled = false;
-/* Set to true to enable memory tracing */
-bool mem_trace = false;
-
-__attribute__((constructor))
-static void
-vac_client_constructor (void)
-{
- clib_mem_init (0, 1 << 30);
- if (mem_trace)
- clib_mem_trace (1);
-}
-
-__attribute__((destructor))
-static void
-vac_client_destructor (void)
-{
- if (mem_trace)
- fformat(stderr, "TRACE: %s",
- format (0, "%U\n",
- format_mheap, clib_mem_get_heap (), 1));
-}
-
-
static void
init (void)
{
@@ -308,12 +286,13 @@ vac_msg_table_size(void)
int
vac_connect (char * name, char * chroot_prefix, vac_callback_t cb,
- int rx_qlen)
+ int rx_qlen)
{
rx_thread_done = false;
int rv = 0;
vac_main_t *pm = &vac_main;
+ assert (clib_mem_get_heap ());
init();
if (chroot_prefix != NULL)
vl_set_memory_root_path (chroot_prefix);
@@ -575,5 +554,18 @@ vac_msg_table_max_index(void)
void
vac_set_error_handler (vac_error_callback_t cb)
{
+ assert (clib_mem_get_heap ());
if (cb) clib_error_register_handler (cb, 0);
}
+
+/*
+ * Required if application doesn't use a VPP heap.
+ */
+void
+vac_mem_init (size_t size)
+{
+ if (size == 0)
+ clib_mem_init (0, 1 << 30); // default
+ else
+ clib_mem_init (0, size);
+}
diff --git a/src/vpp-api/client/vppapiclient.h b/src/vpp-api/client/vppapiclient.h
index 839ec1f851f..680003e7d4f 100644
--- a/src/vpp-api/client/vppapiclient.h
+++ b/src/vpp-api/client/vppapiclient.h
@@ -16,6 +16,7 @@
#define included_vppapiclient_h
#include <stdint.h>
+#include <stdbool.h>
typedef void (*vac_callback_t)(unsigned char * data, int len);
typedef void (*vac_error_callback_t)(void *, unsigned char *, int);
@@ -33,4 +34,6 @@ int vac_msg_table_max_index(void);
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
+void vac_mem_init (size_t size);
+
#endif
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
index 2563a6e89a8..fbf19e4846f 100644
--- a/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
+++ b/src/vpp-api/python/vpp_papi/vpp_transport_shmem.py
@@ -24,7 +24,8 @@ int vac_msg_table_max_index(void);
void vac_rx_suspend (void);
void vac_rx_resume (void);
void vac_set_error_handler(vac_error_callback_t);
- """)
+void vac_mem_init (size_t size);
+""")
vpp_object = None
@@ -67,6 +68,8 @@ class VppTransport(object):
global vpp_object
vpp_object = parent
+ vpp_api.vac_mem_init(0);
+
# Register error handler
vpp_api.vac_set_error_handler(vac_error_handler)