From 9f299030fd1214eb1fc076cf0c7f44559a7c8f6b Mon Sep 17 00:00:00 2001 From: liuyacan Date: Sun, 25 Apr 2021 20:11:30 +0800 Subject: session: fix race condition in fifo allocation Under some timing conditions,VCL may receive CONNECTED/ACCEPTED event before ADD_SEGMENT event. Timing example: 2 threads call segment_manager_alloc_session_fifos() parallelly Thread 1 Thread 2 sm read lock | | | try to alloc fifo =>failed | | | sm read unlock | | | sm write lock | | | add segment | | | sm write unlock | | sm read lock | | | try to alloc fifo=>successful sm read lock | | sm read unlock | | | emit CONNECTED/ACCEPTED emit ADD_SEGMENT event | sm read unlock This commit move ADD_SEGMENT notification under the protection of the write lock in some scenarios. Type: fix Signed-off-by: liuyacan Change-Id: I25d5475c5e6d37cfccefa9506f6030c26ce8ee9b --- src/plugins/unittest/segment_manager_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/unittest/segment_manager_test.c b/src/plugins/unittest/segment_manager_test.c index c6f52972e51..31b417aef24 100644 --- a/src/plugins/unittest/segment_manager_test.c +++ b/src/plugins/unittest/segment_manager_test.c @@ -448,7 +448,7 @@ segment_manager_test_fifo_balanced_alloc (vlib_main_t * vm, } /* add another 2MB segment */ - fs_index = segment_manager_add_segment (sm, size_2MB); + fs_index = segment_manager_add_segment (sm, size_2MB, 0); SEG_MGR_TEST ((fs_index == 1), "fs_index %d", fs_index); /* allocate fifos : 4KB x2 -- cgit 1.2.3-korg