diff options
author | Florin Coras <fcoras@cisco.com> | 2020-04-04 22:45:34 +0000 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-04-06 14:53:17 +0000 |
commit | 57660d9df62756c5db1516be0dbb48505f996e82 (patch) | |
tree | ee671df3eda25c82fa684f12c6542ada65e60d7d /src/vnet/session/segment_manager.c | |
parent | a2ffc6c2fee60a2289aa9aa549de8a88e4ca2d98 (diff) |
session udp: shared local endpoints
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ie7102355b95eefb233ec7d146e61819051a7bf07
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r-- | src/vnet/session/segment_manager.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index 154c7a61880..716f2a39a4e 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -211,6 +211,15 @@ segment_manager_del_segment (segment_manager_t * sm, fifo_segment_t * fs) pool_put (sm->segments, fs); } +static fifo_segment_t * +segment_manager_get_segment_if_valid (segment_manager_t * sm, + u32 segment_index) +{ + if (pool_is_free_index (sm->segments, segment_index)) + return 0; + return pool_elt_at_index (sm->segments, segment_index); +} + /** * Removes segment after acquiring writer lock */ @@ -221,15 +230,18 @@ segment_manager_lock_and_del_segment (segment_manager_t * sm, u32 fs_index) u8 is_prealloc; clib_rwlock_writer_lock (&sm->segments_rwlock); - fs = segment_manager_get_segment (sm, fs_index); + + fs = segment_manager_get_segment_if_valid (sm, fs_index); + if (!fs) + goto done; + is_prealloc = fifo_segment_flags (fs) & FIFO_SEGMENT_F_IS_PREALLOCATED; if (is_prealloc && !segment_manager_app_detached (sm)) - { - clib_rwlock_writer_unlock (&sm->segments_rwlock); - return; - } + goto done; segment_manager_del_segment (sm, fs); + +done: clib_rwlock_writer_unlock (&sm->segments_rwlock); } |