summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/segment_manager.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-11-30 20:21:57 -0800
committerDamjan Marion <dmarion@me.com>2021-12-22 20:53:32 +0000
commitc824977ed38738985864c4524510f37a41453f7d (patch)
treee3ffc4e6bd0c3fccc1e3c1106a8ee1b9127bd511 /src/vnet/session/segment_manager.h
parentd51250f5e2bc99784399b196733e813fef000d71 (diff)
session: fix segment alloc/free worker race
Avoid scenarios where a worker allocates a segment but while it drops the segment manager writer lock and acquires the reader lock another worker uses the segment and frees it. Type: fix Thanks to wanghanlin@corp.netease.com for the report. Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I0a88d738c51b33fd07c34916f125c98806861a06
Diffstat (limited to 'src/vnet/session/segment_manager.h')
-rw-r--r--src/vnet/session/segment_manager.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index 5a3d772ff02..8b722a02324 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -102,8 +102,23 @@ segment_manager_t *segment_manager_get (u32 index);
segment_manager_t *segment_manager_get_if_valid (u32 index);
u32 segment_manager_index (segment_manager_t * sm);
+/**
+ * Add segment without lock
+ *
+ * @param sm Segment manager
+ * @param segment_size Size of segment to be added
+ * @param notify_app Flag set if app notification requested
+ */
int segment_manager_add_segment (segment_manager_t *sm, uword segment_size,
u8 notify_app);
+
+/**
+ * Add segment with lock
+ *
+ * @param sm Segment manager
+ * @param segment_size Size of segment to be added
+ * @param flags Flags to be set on segment
+ */
int segment_manager_add_segment2 (segment_manager_t *sm, uword segment_size,
u8 flags);
void segment_manager_del_segment (segment_manager_t * sm,
@@ -122,7 +137,6 @@ u64 segment_manager_make_segment_handle (u32 segment_manager_index,
u64 segment_manager_segment_handle (segment_manager_t * sm,
fifo_segment_t * segment);
void segment_manager_segment_reader_unlock (segment_manager_t * sm);
-void segment_manager_segment_writer_unlock (segment_manager_t * sm);
int segment_manager_alloc_session_fifos (segment_manager_t * sm,
u32 thread_index,