diff options
author | liuyacan <liuyacan@corp.netease.com> | 2021-04-25 20:11:30 +0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2021-04-26 04:25:40 +0000 |
commit | 9f299030fd1214eb1fc076cf0c7f44559a7c8f6b (patch) | |
tree | 160e1c524b4e14cfd0c63ae86e9b80a336fc7c50 /src/vnet/session/application_local.c | |
parent | b14c49d2275f6348640572b7b481dad43f3a00d0 (diff) |
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 <liuyacan@corp.netease.com>
Change-Id: I25d5475c5e6d37cfccefa9506f6030c26ce8ee9b
Diffstat (limited to 'src/vnet/session/application_local.c')
-rw-r--r-- | src/vnet/session/application_local.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index 478fc7a933b..12209527cb9 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -188,7 +188,7 @@ ct_init_accepted_session (app_worker_t * server_wrk, seg_size = 4 * (round_rx_fifo_sz + round_tx_fifo_sz + margin); sm = app_worker_get_listen_segment_manager (server_wrk, ll); - seg_index = segment_manager_add_segment (sm, seg_size); + seg_index = segment_manager_add_segment (sm, seg_size, 0); if (seg_index < 0) { clib_warning ("failed to add new cut-through segment"); |