diff options
author | Ole Troan <ot@cisco.com> | 2017-08-17 11:07:33 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2017-08-18 16:46:30 +0000 |
commit | 3cdc25ffbaa572639f99e197172c568e4324bc03 (patch) | |
tree | 268a6e9597028620d5b3d442f658921902a4eec5 /src/svm | |
parent | 8ea8916bb8fa85b298e0e5700ba15e4455235015 (diff) |
API: More gracefully fail when opening shared memory segment fails.
API clients would fail with an ASSERT (and core dump) whenever
the API shared memory segment could not be opened.
This returns an error value to the client's connect instead.
Change-Id: Id122a3a090b24b139c382ae09f341bde61fd2540
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/svm')
-rw-r--r-- | src/svm/svm.c | 13 | ||||
-rw-r--r-- | src/svm/svm_common.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/svm/svm.c b/src/svm/svm.c index 0442ecb2950..663324e0a77 100644 --- a/src/svm/svm.c +++ b/src/svm/svm.c @@ -733,7 +733,7 @@ svm_mutex_cleanup (void) } } -static void +static int svm_region_init_internal (svm_map_region_args_t * a) { svm_region_t *rp; @@ -742,7 +742,7 @@ svm_region_init_internal (svm_map_region_args_t * a) /* guard against klutz calls */ if (root_rp) - return; + return -1; root_rp_refcount++; @@ -757,7 +757,8 @@ svm_region_init_internal (svm_map_region_args_t * a) a->baseva += randomize_baseva; rp = svm_map_region (a); - ASSERT (rp); + if (!rp) + return -1; region_lock (rp, 3); @@ -778,6 +779,8 @@ svm_region_init_internal (svm_map_region_args_t * a) } region_unlock (rp); root_rp = rp; + + return 0; } void @@ -797,7 +800,7 @@ svm_region_init (void) svm_region_init_internal (a); } -void +int svm_region_init_chroot (const char *root_path) { svm_map_region_args_t _a, *a = &_a; @@ -811,7 +814,7 @@ svm_region_init_chroot (const char *root_path) a->uid = 0; a->gid = 0; - svm_region_init_internal (a); + return svm_region_init_internal (a); } void diff --git a/src/svm/svm_common.h b/src/svm/svm_common.h index 1f184432967..1f6d83c0a37 100644 --- a/src/svm/svm_common.h +++ b/src/svm/svm_common.h @@ -110,7 +110,7 @@ typedef struct void *svm_region_find_or_create (svm_map_region_args_t * a); void svm_region_init (void); -void svm_region_init_chroot (const char *root_path); +int svm_region_init_chroot (const char *root_path); void svm_region_init_chroot_uid_gid (const char *root_path, int uid, int gid); void svm_region_init_args (svm_map_region_args_t * a); void svm_region_exit (void); |