From c11ce3ee2552c363879082ed8cff048d87389eb9 Mon Sep 17 00:00:00 2001 From: Michael Qiu Date: Fri, 8 Jul 2016 15:28:41 +0800 Subject: plugins/vcgn-plugin: Fix vpp hang with pthread spinlock Currently, pthread spinlock is initialized in macro ASSERT, thus the spinlock only will be initialized when CLIB_ASSERT_ENABLE is true. But CLIB_ASSERT_ENABLE depends on CLIB_DEBUG been set. Mostly, CLIB_DEBUG is zero, so spinlock will never been initialized, which will lead vpp hang when try to hold the lock. This patch fix this issue. Change-Id: If01982b5df849834ccbc705f8e9291f2b6c32d0a Signed-off-by: Michael Qiu --- plugins/vcgn-plugin/vcgn/cnat_db_v2.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/vcgn-plugin/vcgn/cnat_db_v2.c b/plugins/vcgn-plugin/vcgn/cnat_db_v2.c index 2b43849d..46af9f31 100644 --- a/plugins/vcgn-plugin/vcgn/cnat_db_v2.c +++ b/plugins/vcgn-plugin/vcgn/cnat_db_v2.c @@ -3675,7 +3675,7 @@ VLIB_REGISTER_NODE (cnat_db_v2_node) = { void cnat_db_v2_init (void) { - u32 i, n; + u32 i, n, lockinit; cnat_timeout_db_entry_t * tdb __attribute__((unused)); cgse_nat_db_entry_t *comb_db __attribute__((unused)); @@ -3788,15 +3788,19 @@ void cnat_db_v2_init (void) clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); - ASSERT (pthread_spin_init(cnat_db_v2_main.main_db_lockp, - PTHREAD_PROCESS_PRIVATE) == 0); - ASSERT (pthread_spin_init(cnat_db_v2_main.user_db_lockp, - PTHREAD_PROCESS_PRIVATE) == 0); - ASSERT (pthread_spin_init(cnat_db_v2_main.session_db_lockp, - PTHREAD_PROCESS_PRIVATE) == 0); + lockinit = pthread_spin_init(cnat_db_v2_main.main_db_lockp, + PTHREAD_PROCESS_PRIVATE); + ASSERT (lockinit == 0); + + lockinit = pthread_spin_init(cnat_db_v2_main.user_db_lockp, + PTHREAD_PROCESS_PRIVATE); + ASSERT (lockinit == 0); + + lockinit = pthread_spin_init(cnat_db_v2_main.session_db_lockp, + PTHREAD_PROCESS_PRIVATE); + ASSERT (lockinit == 0); cnat_db_init_done = 1; printf("CNAT DB init is successful\n"); return; - //return 0; } -- cgit 1.2.3-korg