diff options
author | Dave Barach <dbarach@cisco.com> | 2018-12-27 13:57:41 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2018-12-31 17:39:33 +0000 |
commit | 22af447454cf097ac4fc59f9072d805c371ab803 (patch) | |
tree | 6e32a5ca5dc37d082e91d2e34eb09dd7fca5a18a /src/vlibmemory | |
parent | c879c149d66d556b9b8183374c601004cecbf982 (diff) |
binary api clients: wait for vpp to start
Change-Id: I740a7423327b724e88fdfa35d90cb1285e9f9746
Signed-off-by: Dave Barach <dbarach@cisco.com>
Diffstat (limited to 'src/vlibmemory')
-rw-r--r-- | src/vlibmemory/memory_shared.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c index d6b2b9887d0..1ccd563639f 100644 --- a/src/vlibmemory/memory_shared.c +++ b/src/vlibmemory/memory_shared.c @@ -532,6 +532,35 @@ vl_map_shmem (const char *region_name, int is_vlib) if (is_vlib == 0) { + int tfd; + u8 *api_name; + /* + * Clients wait for vpp to set up the root / API regioins + */ + if (am->root_path) + api_name = format (0, "/dev/shm/%s-%s%c", am->root_path, + region_name + 1, 0); + else + api_name = format (0, "/dev/shm%s%c", region_name, 0); + + /* Wait up to 100 seconds... */ + for (i = 0; i < 10000; i++) + { + ts.tv_sec = 0; + ts.tv_nsec = 10000 * 1000; /* 10 ms */ + while (nanosleep (&ts, &tsrem) < 0) + ts = tsrem; + tfd = open ((char *) api_name, O_RDWR); + if (tfd > 0) + break; + } + vec_free (api_name); + if (tfd < 0) + { + clib_warning ("region init fail"); + return -2; + } + close (tfd); rv = svm_region_init_chroot (am->root_path); if (rv) return rv; |