From 0aa4013e20471a7b23bc3252649c95c81b5d7519 Mon Sep 17 00:00:00 2001 From: Nathan Skrzypczak Date: Mon, 25 Nov 2019 16:29:38 +0100 Subject: api: Use vl_msg_push/pop_heap Type: refactor Change-Id: I0eb46676fc22ce6825b2d879498df344b5a855e8 Signed-off-by: Nathan Skrzypczak --- src/vlibmemory/memory_shared.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/vlibmemory/memory_shared.c') diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index 0b232adf899..1716f271466 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -163,15 +163,13 @@ vl_msg_api_alloc_internal (svm_region_t * vlib_rp, int nbytes, int pool, */ am->ring_misses++; - pthread_mutex_lock (&vlib_rp->mutex); - oldheap = svm_push_data_heap (vlib_rp); + oldheap = vl_msg_push_heap_w_region (vlib_rp); if (may_return_null) { rv = clib_mem_alloc_or_null (nbytes); if (PREDICT_FALSE (rv == 0)) { - svm_pop_heap (oldheap); - pthread_mutex_unlock (&vlib_rp->mutex); + vl_msg_pop_heap_w_region (vlib_rp, oldheap); return 0; } } @@ -180,8 +178,7 @@ vl_msg_api_alloc_internal (svm_region_t * vlib_rp, int nbytes, int pool, rv->q = 0; rv->gc_mark_timestamp = 0; - svm_pop_heap (oldheap); - pthread_mutex_unlock (&vlib_rp->mutex); + vl_msg_pop_heap_w_region (vlib_rp, oldheap); out: #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 @@ -296,8 +293,7 @@ vl_msg_api_free_w_region (svm_region_t * vlib_rp, void *a) return; } - pthread_mutex_lock (&vlib_rp->mutex); - oldheap = svm_push_data_heap (vlib_rp); + oldheap = vl_msg_push_heap_w_region (vlib_rp); #if DEBUG_MESSAGE_BUFFER_OVERRUN > 0 { @@ -308,8 +304,7 @@ vl_msg_api_free_w_region (svm_region_t * vlib_rp, void *a) #endif clib_mem_free (rv); - svm_pop_heap (oldheap); - pthread_mutex_unlock (&vlib_rp->mutex); + vl_msg_pop_heap_w_region (vlib_rp, oldheap); } void -- cgit 1.2.3-korg