22 #include <sys/types.h> 25 #include <netinet/in.h> 48 u8 * var,
u8 * val,
u32 elsize);
53 pthread_mutex_lock (&rp->
mutex);
67 pthread_mutex_unlock (&rp->
mutex);
102 client->
pid = getpid ();
113 (
"[%d] adding fake client (pid=0) so '%s' won't be unlinked",
133 client->
pid = getpid ();
158 u32 *dead_registrations = 0;
172 if (sigqueue (np->
pid, np->
signum, sv) == 0)
176 while (rv == EAGAIN);
183 for (i = 0; i <
vec_len (dead_registrations); i++)
186 clib_warning (
"dead reg pid %d sig %d action %d opaque %x",
231 if ((np->
pid == client->
pid)
243 (
"%s: ignore dup reg pid %d signum %d action %d opaque %x",
285 _vec_len (oldvalue->
value) = 0;
305 u8 * var,
u8 * val,
u32 elsize)
329 newvalue->
elsize = elsize;
333 name =
format (0,
"%s%c", var, 0);
341 char *var,
char *val)
351 (
u8 *) var, (
u8 *) val, 1 );
372 return (oldvalue->
value);
399 rv =
format (0,
"%s", rv);
403 return ((
char *) rv);
423 fformat(stdout,
"%s: %s\n", key,
439 u8 *sanitized_name = 0;
442 if (strstr (filename,
"..") || index (filename,
'/'))
449 sanitized_name =
format (0,
"/tmp/%s%c", filename, 0);
451 fd = creat ((
char *) sanitized_name, 0644);
485 if (fd > 0 && close (fd) < 0)
507 fd = open (filename, O_RDONLY);
522 for (i = 0; i < nelts; i++)
537 if (fd > 0 && close (fd) < 0)
562 char *var,
void *val_arg,
u32 elsize)
564 u8 *val = (
u8 *) val_arg;
593 _vec_len (copy) =
vec_len (rv);
618 (void)
fformat(stdout,
"%s:\n %U (%.2f)\n", key,
629 char *var,
u32 nbytes)
657 _vec_len (newvalue->
value) = nbytes;
658 name =
format (0,
"%s%c", var, 0);
661 rv = newvalue->
value;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void svm_region_init_chroot_uid_gid(const char *root_path, int uid, int gid)
svm_region_t * svm_get_root_rp(void)
static void svm_pop_heap(void *oldheap)
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
void * svmdb_local_get_variable_reference(svmdb_client_t *client, svmdb_namespace_t namespace, char *var)
Optimized string handling code, including c11-compliant "safe C library" variants.
#define SVMDB_SHM_VERSION
void svmdb_local_dump_vecs(svmdb_client_t *client)
Fixed length block allocator.
void svmdb_local_unset_vec_variable(svmdb_client_t *client, char *var)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define hash_set_mem(h, key, value)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define hash_get_pair_mem(h, key)
static void region_lock(svm_region_t *rp, int tag)
void serialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_alloc(V, N)
Allocate space for N more elements (no header, unspecified alignment)
void svmdb_unmap(svmdb_client_t *client)
#define clib_memcpy(d, s, n)
void svm_region_exit(void)
void svmdb_local_dump_strings(svmdb_client_t *client)
static void * svm_push_data_heap(svm_region_t *rp)
uword * namespaces[SVMDB_N_NAMESPACES]
void * svm_region_find_or_create(svm_map_region_args_t *a)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
int svmdb_local_serialize_strings(svmdb_client_t *client, char *filename)
#define clib_error_return(e, args...)
#define hash_create_string(elts, value_bytes)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define SVMDB_DEFAULT_SIZE
static void serialize_likely_small_unsigned_integer(serialize_main_t *m, u64 x)
char * svmdb_local_get_string_variable(svmdb_client_t *client, char *var)
#define clib_error_return_unix(e, args...)
#define hash_foreach_mem(key_var, value_var, h, body)
void unserialize_cstring(serialize_main_t *m, char **s)
static void * svm_push_pvt_heap(svm_region_t *rp)
static void local_unset_variable_nolock(svmdb_client_t *client, svmdb_namespace_t namespace, char *var)
static u8 * local_get_variable_nolock(svmdb_client_t *client, svmdb_namespace_t namespace, u8 *var)
int svmdb_local_unserialize_strings(svmdb_client_t *client, char *filename)
void * svmdb_local_find_or_add_vec_variable(svmdb_client_t *client, char *var, u32 nbytes)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
void svmdb_local_set_vec_variable(svmdb_client_t *client, char *var, void *val_arg, u32 elsize)
svmdb_notify_t * notifications
static uword hash_elts(void *v)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
void serialize_close(serialize_main_t *m)
Bitmaps built as vectors of machine words.
int svmdb_local_add_del_notification(svmdb_client_t *client, svmdb_notification_args_t *a)
#define clib_error_report(e)
void serialize_cstring(serialize_main_t *m, char *s)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void svmdb_local_unset_string_variable(svmdb_client_t *client, char *var)
static void local_set_variable_nolock(svmdb_client_t *client, svmdb_namespace_t namespace, u8 *var, u8 *val, u32 elsize)
void svm_region_unmap(void *rp_arg)
svmdb_client_t * svmdb_map(svmdb_map_args_t *dba)
void * svmdb_local_get_vec_variable(svmdb_client_t *client, char *var, u32 elsize)
#define hash_get_mem(h, key)
void unserialize_open_clib_file_descriptor(serialize_main_t *m, int fd)
void svmdb_local_set_string_variable(svmdb_client_t *client, char *var, char *val)
static void region_unlock(svm_region_t *rp)
static void notify_value(svmdb_value_t *v, svmdb_action_t a)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".