vlib: always replace bootstrap vlib_mains
Fixes an obscure issue when spinning up pure pthreads which don't have
vlib_main_t clones.
VLIB_REGISTER_THREAD () = {
<snip>
.use_pthreads = 1,
.no_data_structure_clone = 1,
}
Type: improvement
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ifae5a2a35865de057eea7782ee71b1011a21c88e
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 270ccc3..ecca7e3 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -707,16 +707,15 @@
clib_callback_data_init (&vm->vlib_node_runtime_perf_callbacks,
&vm->worker_thread_main_loop_callback_lock);
+ /* Replace hand-crafted length-1 vector with a real vector */
+ vlib_mains = 0;
+
+ vec_validate_aligned (vlib_mains, n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES);
+ _vec_len (vlib_mains) = 0;
+ vec_add1_aligned (vlib_mains, vm, CLIB_CACHE_LINE_BYTES);
+
if (n_vlib_mains > 1)
{
- /* Replace hand-crafted length-1 vector with a real vector */
- vlib_mains = 0;
-
- vec_validate_aligned (vlib_mains, tm->n_vlib_mains - 1,
- CLIB_CACHE_LINE_BYTES);
- _vec_len (vlib_mains) = 0;
- vec_add1_aligned (vlib_mains, vm, CLIB_CACHE_LINE_BYTES);
-
vlib_worker_threads->wait_at_barrier =
clib_mem_alloc_aligned (sizeof (u32), CLIB_CACHE_LINE_BYTES);
vlib_worker_threads->workers_at_barrier =