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 ();
128 client->
pid = getpid ();
153 u32 *dead_registrations = 0;
163 sv.sival_ptr = (
void *) (
uword) value;
167 if (sigqueue (np->
pid, np->
signum, sv) == 0)
171 while (rv == EAGAIN);
178 for (i = 0; i <
vec_len (dead_registrations); i++)
181 clib_warning (
"dead reg pid %d sig %d action %d opaque %x",
226 if ((np->
pid == client->
pid)
238 (
"%s: ignore dup reg pid %d signum %d action %d opaque %x",
280 _vec_len (oldvalue->
value) = 0;
300 u8 * var,
u8 * val,
u32 elsize)
323 memset (newvalue, 0,
sizeof (*newvalue));
324 newvalue->
elsize = elsize;
328 name =
format (0,
"%s%c", var, 0);
336 char *var,
char *val)
346 (
u8 *) var, (
u8 *) val, 1 );
367 return (oldvalue->
value);
394 rv =
format (0,
"%s", rv);
398 return ((
char *) rv);
418 fformat(stdout,
"%s: %s\n", key,
434 u8 *sanitized_name = 0;
437 if (strstr (filename,
"..") || index (filename,
'/'))
444 sanitized_name =
format (0,
"/tmp/%s%c", filename, 0);
446 fd = creat ((
char *) sanitized_name, 0644);
480 if (fd > 0 && close (fd) < 0)
502 fd = open (filename, O_RDONLY);
517 for (i = 0; i < nelts; i++)
532 if (fd > 0 && close (fd) < 0)
557 char *var,
void *val_arg,
u32 elsize)
559 u8 *val = (
u8 *) val_arg;
588 _vec_len (copy) =
vec_len (rv);
613 (void)
fformat(stdout,
"%s:\n %U (%.2f)\n", key,
624 char *var,
u32 nbytes)
649 memset (newvalue, 0,
sizeof (*newvalue));
652 _vec_len (newvalue->
value) = nbytes;
653 name =
format (0,
"%s%c", var, 0);
656 rv = newvalue->
value;
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
svm_region_t * svm_get_root_rp(void)
sll srl srl sll sra u16x4 i
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)
#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)
#define hash_get_pair_mem(h, key)
static void region_lock(svm_region_t *rp, int tag)
#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)
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...)
void unserialize_open_unix_file_descriptor(serialize_main_t *m, int fd)
#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...)
#define clib_memcpy(a, b, c)
void svm_region_init_chroot_uid_gid(char *root_path, int uid, int gid)
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)
void serialize_open_unix_file_descriptor(serialize_main_t *m, int fd)
#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 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".