30 return SSVM_API_ERROR_NO_SIZE;
32 ssvm_filename =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
34 unlink ((
char *) ssvm_filename);
38 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR | O_CREAT | O_EXCL, 0777);
43 return SSVM_API_ERROR_CREATE_FAILURE;
46 if (lseek (ssvm_fd, ssvm->
ssvm_size, SEEK_SET) < 0)
50 return SSVM_API_ERROR_SET_SIZE;
53 if (write (ssvm_fd, &junk, 1) != 1)
57 return SSVM_API_ERROR_SET_SIZE;
74 if (ssvm->
sh == MAP_FAILED)
78 return SSVM_API_ERROR_MMAP;
112 while (timeout_in_seconds-- > 0)
115 ssvm_fd = shm_open ((
char *) ssvm->
name, O_RDWR, 0777);
121 if (fstat (ssvm_fd, &stat) < 0)
127 if (stat.st_size > 0)
131 return SSVM_API_ERROR_SLAVE_TIMEOUT;
134 sh = (
void *) mmap (0,
MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
136 if (sh == MAP_FAILED)
140 return SSVM_API_ERROR_MMAP;
143 while (timeout_in_seconds-- > 0)
151 return SSVM_API_ERROR_SLAVE_TIMEOUT;
159 PROT_READ | PROT_WRITE,
160 MAP_SHARED | MAP_FIXED, ssvm_fd, 0);
162 if (sh == MAP_FAILED)
166 return SSVM_API_ERROR_MMAP;
177 fn =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
180 if (unlink ((
char *) fn) < 0)
int ssvm_master_init(ssvm_private_t *ssvm, u32 master_index)
static u64 clib_cpu_time_now(void)
ssvm_shared_header_t * sh
#define MHEAP_FLAG_THREAD_SAFE
void ssvm_delete(ssvm_private_t *ssvm)
#define MHEAP_FLAG_DISABLE_VM
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
static void ssvm_pop_heap(void *oldheap)
static uword pointer_to_uword(const void *p)
int ssvm_slave_init(ssvm_private_t *ssvm, int timeout_in_seconds)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
#define clib_unix_warning(format, args...)