aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-04-12 13:04:16 -0700
committerFlorin Coras <fcoras@cisco.com>2019-04-12 13:04:16 -0700
commitbbf923fb52e8a9062ef4d740288cf5547c4dbde4 (patch)
tree02745678ba6f3077316a82d76ebf87b5697327c3
parent1c9a58decd525ad46487b120642883089fb5758f (diff)
session: drop lock on segment allocation error
Change-Id: Ib346570daa3e40f4f53100a05e9355ce60d533a4 Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--src/vnet/session/segment_manager.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 25b641de167..c8d4be5c113 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -195,7 +195,7 @@ int
segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
{
segment_manager_main_t *smm = &segment_manager_main;
- u32 rnd_margin = 128 << 10, seg_index, page_size;
+ u32 rnd_margin = 128 << 10, seg_index = ~0, page_size;
segment_manager_properties_t *props;
uword baseva = (uword) ~ 0ULL, alloc_size;
svm_fifo_segment_private_t *seg;
@@ -215,15 +215,9 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
* Allocate fifo segment and lock if needed
*/
if (vlib_num_workers ())
- {
- clib_rwlock_writer_lock (&sm->segments_rwlock);
- pool_get (sm->segments, seg);
- }
- else
- {
- pool_get (sm->segments, seg);
- }
- clib_memset (seg, 0, sizeof (*seg));
+ clib_rwlock_writer_lock (&sm->segments_rwlock);
+
+ pool_get_zero (sm->segments, seg);
/*
* Initialize ssvm segment and svm fifo private header
@@ -239,7 +233,8 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
if (!baseva)
{
clib_warning ("out of space for segments");
- return -1;
+ pool_put (sm->segments, seg);
+ goto done;
}
}
else
@@ -257,7 +252,7 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
if (props->segment_type != SSVM_SEGMENT_PRIVATE)
clib_valloc_free (&smm->va_allocator, baseva);
pool_put (sm->segments, seg);
- return (rv);
+ goto done;
}
svm_fifo_segment_init (seg);
@@ -267,6 +262,8 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
*/
seg_index = seg - sm->segments;
+done:
+
if (vlib_num_workers ())
clib_rwlock_writer_unlock (&sm->segments_rwlock);