mirror of
https://github.com/netdata/netdata.git
synced 2025-04-16 18:37:50 +00:00
Rename struct avl to avl_element and the typedef to avl_t (#10735)
Before: ``` struct foobar { avl avl; ... } ``` After: ``` struct foobar { avl_t avl; ... }; ``` Which makes figuring out the type from field name easier.
This commit is contained in:
parent
86ca37683e
commit
adec24dffa
29 changed files with 136 additions and 136 deletions
collectors
apps.plugin
ebpf.plugin
statsd.plugin
tc.plugin
database
health
libnetdata
registry
spawn
|
@ -491,7 +491,7 @@ typedef enum fd_filetype {
|
|||
} FD_FILETYPE;
|
||||
|
||||
struct file_descriptor {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
#ifdef NETDATA_INTERNAL_CHECKS
|
||||
uint32_t magic;
|
||||
|
@ -514,7 +514,7 @@ static int
|
|||
// read users and groups from files
|
||||
|
||||
struct user_or_group_id {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
union {
|
||||
uid_t uid;
|
||||
|
@ -639,7 +639,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
|
|||
struct user_or_group_id *existing_user_id = NULL;
|
||||
|
||||
if(likely(ids->root))
|
||||
existing_user_id = (struct user_or_group_id *)avl_search(&ids->index, (avl *) user_or_group_id);
|
||||
existing_user_id = (struct user_or_group_id *)avl_search(&ids->index, (avl_t *) user_or_group_id);
|
||||
|
||||
if(unlikely(existing_user_id)) {
|
||||
freez(existing_user_id->name);
|
||||
|
@ -648,7 +648,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
|
|||
freez(user_or_group_id);
|
||||
}
|
||||
else {
|
||||
if(unlikely(avl_insert(&ids->index, (avl *) user_or_group_id) != (void *) user_or_group_id)) {
|
||||
if(unlikely(avl_insert(&ids->index, (avl_t *) user_or_group_id) != (void *) user_or_group_id)) {
|
||||
error("INTERNAL ERROR: duplicate indexing of id during realloc");
|
||||
};
|
||||
|
||||
|
@ -664,7 +664,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
|
|||
|
||||
while(user_or_group_id) {
|
||||
if(unlikely(!user_or_group_id->updated)) {
|
||||
if(unlikely((struct user_or_group_id *)avl_remove(&ids->index, (avl *) user_or_group_id) != user_or_group_id))
|
||||
if(unlikely((struct user_or_group_id *)avl_remove(&ids->index, (avl_t *) user_or_group_id) != user_or_group_id))
|
||||
error("INTERNAL ERROR: removal of unused id from index, removed a different id");
|
||||
|
||||
if(prev_user_id)
|
||||
|
@ -716,7 +716,7 @@ static struct target *get_users_target(uid_t uid) {
|
|||
int ret = read_user_or_group_ids(&all_user_ids, &last_passwd_modification_time);
|
||||
|
||||
if(likely(!ret && all_user_ids.index.root))
|
||||
user_or_group_id = (struct user_or_group_id *)avl_search(&all_user_ids.index, (avl *) &user_id_to_find);
|
||||
user_or_group_id = (struct user_or_group_id *)avl_search(&all_user_ids.index, (avl_t *) &user_id_to_find);
|
||||
}
|
||||
|
||||
if(user_or_group_id && user_or_group_id->name && *user_or_group_id->name) {
|
||||
|
@ -764,7 +764,7 @@ struct target *get_groups_target(gid_t gid)
|
|||
int ret = read_user_or_group_ids(&all_group_ids, &last_group_modification_time);
|
||||
|
||||
if(likely(!ret && all_group_ids.index.root))
|
||||
group_id = (struct user_or_group_id *)avl_search(&all_group_ids.index, (avl *) &group_id_to_find);
|
||||
group_id = (struct user_or_group_id *)avl_search(&all_group_ids.index, (avl_t *) &group_id_to_find);
|
||||
}
|
||||
|
||||
if(group_id && group_id->name && *group_id->name) {
|
||||
|
@ -1690,7 +1690,7 @@ int file_descriptor_compare(void* a, void* b) {
|
|||
return strcmp(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
|
||||
}
|
||||
|
||||
// int file_descriptor_iterator(avl *a) { if(a) {}; return 0; }
|
||||
// int file_descriptor_iterator(avl_t *a) { if(a) {}; return 0; }
|
||||
|
||||
avl_tree_type all_files_index = {
|
||||
NULL,
|
||||
|
@ -1707,11 +1707,11 @@ static struct file_descriptor *file_descriptor_find(const char *name, uint32_t h
|
|||
tmp.magic = 0x0BADCAFE;
|
||||
#endif /* NETDATA_INTERNAL_CHECKS */
|
||||
|
||||
return (struct file_descriptor *)avl_search(&all_files_index, (avl *) &tmp);
|
||||
return (struct file_descriptor *)avl_search(&all_files_index, (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
#define file_descriptor_add(fd) avl_insert(&all_files_index, (avl *)(fd))
|
||||
#define file_descriptor_remove(fd) avl_remove(&all_files_index, (avl *)(fd))
|
||||
#define file_descriptor_add(fd) avl_insert(&all_files_index, (avl_t *)(fd))
|
||||
#define file_descriptor_remove(fd) avl_remove(&all_files_index, (avl_t *)(fd))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1148,7 +1148,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
|
|||
memcpy(&test.index, lindex, sizeof(netdata_socket_idx_t));
|
||||
test.flags = flags;
|
||||
|
||||
ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl *)&test);
|
||||
ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl_t *)&test);
|
||||
if (ret) {
|
||||
if (lvalues->ct > ret->plot.last_time) {
|
||||
update_socket_data(&ret->sock, lvalues);
|
||||
|
@ -1186,7 +1186,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
|
|||
|
||||
w->flags = flags;
|
||||
netdata_socket_plot_t *check ;
|
||||
check = (netdata_socket_plot_t *) avl_insert_lock(&out->tree, (avl *)w);
|
||||
check = (netdata_socket_plot_t *) avl_insert_lock(&out->tree, (avl_t *)w);
|
||||
if (check != w)
|
||||
error("Internal error, cannot insert the AVL tree.");
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ typedef struct netdata_socket_idx {
|
|||
*/
|
||||
typedef struct netdata_socket_plot {
|
||||
// Search
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
netdata_socket_idx_t index;
|
||||
|
||||
// Current data
|
||||
|
|
|
@ -107,7 +107,7 @@ typedef enum statsd_metric_type {
|
|||
|
||||
|
||||
typedef struct statsd_metric {
|
||||
avl avl; // indexing - has to be first
|
||||
avl_t avl; // indexing - has to be first
|
||||
|
||||
const char *name; // the name of the metric
|
||||
uint32_t hash; // hash of the name
|
||||
|
@ -376,7 +376,7 @@ static inline STATSD_METRIC *statsd_metric_index_find(STATSD_INDEX *index, const
|
|||
tmp.name = name;
|
||||
tmp.hash = (hash)?hash:simple_hash(tmp.name);
|
||||
|
||||
return (STATSD_METRIC *)STATSD_AVL_SEARCH(&index->index, (avl *)&tmp);
|
||||
return (STATSD_METRIC *)STATSD_AVL_SEARCH(&index->index, (avl_t *)&tmp);
|
||||
}
|
||||
|
||||
static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name, STATSD_METRIC_TYPE type) {
|
||||
|
@ -398,7 +398,7 @@ static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, cons
|
|||
m->histogram.ext = callocz(sizeof(STATSD_METRIC_HISTOGRAM_EXTENSIONS), 1);
|
||||
netdata_mutex_init(&m->histogram.ext->mutex);
|
||||
}
|
||||
STATSD_METRIC *n = (STATSD_METRIC *)STATSD_AVL_INSERT(&index->index, (avl *)m);
|
||||
STATSD_METRIC *n = (STATSD_METRIC *)STATSD_AVL_INSERT(&index->index, (avl_t *)m);
|
||||
if(unlikely(n != m)) {
|
||||
freez((void *)m->histogram.ext);
|
||||
freez((void *)m->name);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define TC_LINE_MAX 1024
|
||||
|
||||
struct tc_class {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
char *id;
|
||||
uint32_t hash;
|
||||
|
@ -56,7 +56,7 @@ struct tc_class {
|
|||
};
|
||||
|
||||
struct tc_device {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
char *id;
|
||||
uint32_t hash;
|
||||
|
@ -107,15 +107,15 @@ avl_tree_type tc_device_root_index = {
|
|||
tc_device_compare
|
||||
};
|
||||
|
||||
#define tc_device_index_add(st) (struct tc_device *)avl_insert(&tc_device_root_index, (avl *)(st))
|
||||
#define tc_device_index_del(st) (struct tc_device *)avl_remove(&tc_device_root_index, (avl *)(st))
|
||||
#define tc_device_index_add(st) (struct tc_device *)avl_insert(&tc_device_root_index, (avl_t *)(st))
|
||||
#define tc_device_index_del(st) (struct tc_device *)avl_remove(&tc_device_root_index, (avl_t *)(st))
|
||||
|
||||
static inline struct tc_device *tc_device_index_find(const char *id, uint32_t hash) {
|
||||
struct tc_device tmp;
|
||||
tmp.id = (char *)id;
|
||||
tmp.hash = (hash)?hash:simple_hash(tmp.id);
|
||||
|
||||
return (struct tc_device *)avl_search(&(tc_device_root_index), (avl *)&tmp);
|
||||
return (struct tc_device *)avl_search(&(tc_device_root_index), (avl_t *)&tmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,15 +128,15 @@ static int tc_class_compare(void* a, void* b) {
|
|||
else return strcmp(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
|
||||
}
|
||||
|
||||
#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl *)(rd))
|
||||
#define tc_class_index_del(st, rd) (struct tc_class *)avl_remove(&((st)->classes_index), (avl *)(rd))
|
||||
#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl_t *)(rd))
|
||||
#define tc_class_index_del(st, rd) (struct tc_class *)avl_remove(&((st)->classes_index), (avl_t *)(rd))
|
||||
|
||||
static inline struct tc_class *tc_class_index_find(struct tc_device *st, const char *id, uint32_t hash) {
|
||||
struct tc_class tmp;
|
||||
tmp.id = (char *)id;
|
||||
tmp.hash = (hash)?hash:simple_hash(tmp.id);
|
||||
|
||||
return (struct tc_class *)avl_search(&(st->classes_index), (avl *) &tmp);
|
||||
return (struct tc_class *)avl_search(&(st->classes_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -234,4 +234,4 @@ extern void rrdeng_worker(void* arg);
|
|||
extern void rrdeng_enq_cmd(struct rrdengine_worker_config* wc, struct rrdeng_cmd *cmd);
|
||||
extern struct rrdeng_cmd rrdeng_deq_cmd(struct rrdengine_worker_config* wc);
|
||||
|
||||
#endif /* NETDATA_RRDENGINE_H */
|
||||
#endif /* NETDATA_RRDENGINE_H */
|
||||
|
|
|
@ -130,7 +130,7 @@ extern const char *rrd_algorithm_name(RRD_ALGORITHM algorithm);
|
|||
// RRD FAMILY
|
||||
|
||||
struct rrdfamily {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
const char *family;
|
||||
uint32_t hash_family;
|
||||
|
@ -235,7 +235,7 @@ struct rrddim {
|
|||
// ------------------------------------------------------------------------
|
||||
// binary indexing structures
|
||||
|
||||
avl avl; // the binary index - this has to be first member!
|
||||
avl_t avl; // the binary index - this has to be first member!
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// the dimension definition
|
||||
|
@ -474,8 +474,8 @@ struct rrdset {
|
|||
// ------------------------------------------------------------------------
|
||||
// binary indexing structures
|
||||
|
||||
avl avl; // the index, with key the id - this has to be first!
|
||||
avl avlname; // the index, with key the name
|
||||
avl_t avl; // the index, with key the id - this has to be first!
|
||||
avl_t avlname; // the index, with key the name
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// the set configuration
|
||||
|
@ -727,7 +727,7 @@ struct rrdhost_system_info {
|
|||
};
|
||||
|
||||
struct rrdhost {
|
||||
avl avl; // the index of hosts
|
||||
avl_t avl; // the index of hosts
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// host information
|
||||
|
@ -1286,8 +1286,8 @@ extern int rrdfamily_compare(void *a, void *b);
|
|||
extern RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id);
|
||||
extern void rrdfamily_free(RRDHOST *host, RRDFAMILY *rc);
|
||||
|
||||
#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
|
||||
#define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl *)(st))
|
||||
#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl_t *)(st))
|
||||
#define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl_t *)(st))
|
||||
extern RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st);
|
||||
|
||||
extern void rrdset_free(RRDSET *st);
|
||||
|
|
|
@ -472,7 +472,7 @@ inline RRDCALC *rrdcalc_create_from_template(RRDHOST *host, RRDCALCTEMPLATE *rt,
|
|||
|
||||
rrdcalc_add_to_host(host, rc);
|
||||
if(!rt->foreachdim) {
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl *)rc);
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl_t *)rc);
|
||||
if (rdcmp != rc) {
|
||||
error("Cannot insert the alarm index ID %s",rc->name);
|
||||
}
|
||||
|
@ -605,17 +605,17 @@ void rrdcalc_unlink_and_free(RRDHOST *host, RRDCALC *rc) {
|
|||
error("Cannot unlink alarm '%s.%s' from host '%s': not found", rc->chart?rc->chart:"NOCHART", rc->name, host->hostname);
|
||||
}
|
||||
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_health_log, (avl *)rc);
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_health_log, (avl_t *)rc);
|
||||
if (rdcmp) {
|
||||
rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl *)rc);
|
||||
rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl_t *)rc);
|
||||
if (!rdcmp) {
|
||||
error("Cannot remove the health alarm index from health_log");
|
||||
}
|
||||
}
|
||||
|
||||
rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_name, (avl *)rc);
|
||||
rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_name, (avl_t *)rc);
|
||||
if (rdcmp) {
|
||||
rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl *)rc);
|
||||
rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl_t *)rc);
|
||||
if (!rdcmp) {
|
||||
error("Cannot remove the health alarm index from idx_name");
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ void rrdcalc_labels_unlink() {
|
|||
int alarm_isrepeating(RRDHOST *host, uint32_t alarm_id) {
|
||||
RRDCALC findme;
|
||||
findme.id = alarm_id;
|
||||
RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_health_log, (avl *)&findme);
|
||||
RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_health_log, (avl_t *)&findme);
|
||||
if (!rc) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ RRDCALC *alarm_max_last_repeat(RRDHOST *host, char *alarm_name,uint32_t hash) {
|
|||
RRDCALC findme;
|
||||
findme.name = alarm_name;
|
||||
findme.hash = hash;
|
||||
RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_name, (avl *)&findme);
|
||||
RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_name, (avl_t *)&findme);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
|
||||
struct rrdcalc {
|
||||
avl avl; // the index, with key the id - this has to be first!
|
||||
avl_t avl; // the index, with key the id - this has to be first!
|
||||
uint32_t id; // the unique id of this alarm
|
||||
uint32_t next_event_id; // the next event id that will be used for this alarm
|
||||
|
||||
|
|
|
@ -38,15 +38,15 @@ int rrddim_compare(void* a, void* b) {
|
|||
else return strcmp(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
|
||||
}
|
||||
|
||||
#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl *)(rd))
|
||||
#define rrddim_index_del(st,rd ) (RRDDIM *)avl_remove_lock(&((st)->dimensions_index), (avl *)(rd))
|
||||
#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl_t *)(rd))
|
||||
#define rrddim_index_del(st,rd ) (RRDDIM *)avl_remove_lock(&((st)->dimensions_index), (avl_t *)(rd))
|
||||
|
||||
static inline RRDDIM *rrddim_index_find(RRDSET *st, const char *id, uint32_t hash) {
|
||||
RRDDIM tmp = {
|
||||
.id = id,
|
||||
.hash = (hash)?hash:simple_hash(id)
|
||||
};
|
||||
return (RRDDIM *)avl_search_lock(&(st->dimensions_index), (avl *) &tmp);
|
||||
return (RRDDIM *)avl_search_lock(&(st->dimensions_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@ void rrdcalc_link_to_rrddim(RRDDIM *rd, RRDSET *st, RRDHOST *host) {
|
|||
RRDCALC *child = rrdcalc_create_from_rrdcalc(rrdc, host, usename, rd->name);
|
||||
if (child) {
|
||||
rrdcalc_add_to_host(host, child);
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl *)child);
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl_t *)child);
|
||||
if (rdcmp != child) {
|
||||
error("Cannot insert the alarm index ID %s",child->name);
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte
|
|||
if(likely(rd)) {
|
||||
// we have a file mapped for rd
|
||||
|
||||
memset(&rd->avl, 0, sizeof(avl));
|
||||
memset(&rd->avl, 0, sizeof(avl_t));
|
||||
rd->id = NULL;
|
||||
rd->name = NULL;
|
||||
rd->cache_filename = NULL;
|
||||
|
|
|
@ -12,15 +12,15 @@ int rrdfamily_compare(void *a, void *b) {
|
|||
else return strcmp(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
|
||||
}
|
||||
|
||||
#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
|
||||
#define rrdfamily_index_del(host, rc) (RRDFAMILY *)avl_remove_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
|
||||
#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl_t *)(rc))
|
||||
#define rrdfamily_index_del(host, rc) (RRDFAMILY *)avl_remove_lock(&((host)->rrdfamily_root_index), (avl_t *)(rc))
|
||||
|
||||
static RRDFAMILY *rrdfamily_index_find(RRDHOST *host, const char *id, uint32_t hash) {
|
||||
RRDFAMILY tmp;
|
||||
tmp.family = id;
|
||||
tmp.hash_family = (hash)?hash:simple_hash(tmp.family);
|
||||
|
||||
return (RRDFAMILY *)avl_search_lock(&(host->rrdfamily_root_index), (avl *) &tmp);
|
||||
return (RRDFAMILY *)avl_search_lock(&(host->rrdfamily_root_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id) {
|
||||
|
|
|
@ -31,7 +31,7 @@ RRDHOST *rrdhost_find_by_guid(const char *guid, uint32_t hash) {
|
|||
strncpyz(tmp.machine_guid, guid, GUID_LEN);
|
||||
tmp.hash_machine_guid = (hash)?hash:simple_hash(tmp.machine_guid);
|
||||
|
||||
return (RRDHOST *)avl_search_lock(&(rrdhost_root_index), (avl *) &tmp);
|
||||
return (RRDHOST *)avl_search_lock(&(rrdhost_root_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash) {
|
||||
|
@ -53,8 +53,8 @@ RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#define rrdhost_index_add(rrdhost) (RRDHOST *)avl_insert_lock(&(rrdhost_root_index), (avl *)(rrdhost))
|
||||
#define rrdhost_index_del(rrdhost) (RRDHOST *)avl_remove_lock(&(rrdhost_root_index), (avl *)(rrdhost))
|
||||
#define rrdhost_index_add(rrdhost) (RRDHOST *)avl_insert_lock(&(rrdhost_root_index), (avl_t *)(rrdhost))
|
||||
#define rrdhost_index_del(rrdhost) (RRDHOST *)avl_remove_lock(&(rrdhost_root_index), (avl_t *)(rrdhost))
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -35,7 +35,7 @@ static RRDSET *rrdset_index_find(RRDHOST *host, const char *id, uint32_t hash) {
|
|||
strncpyz(tmp.id, id, RRD_ID_LENGTH_MAX);
|
||||
tmp.hash = (hash)?hash:simple_hash(tmp.id);
|
||||
|
||||
return (RRDSET *)avl_search_lock(&(host->rrdset_root_index), (avl *) &tmp);
|
||||
return (RRDSET *)avl_search_lock(&(host->rrdset_root_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -57,7 +57,7 @@ int rrdset_compare_name(void* a, void* b) {
|
|||
RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
|
||||
void *result;
|
||||
// fprintf(stderr, "ADDING: %s (name: %s)\n", st->id, st->name);
|
||||
result = avl_insert_lock(&host->rrdset_root_index_name, (avl *) (&st->avlname));
|
||||
result = avl_insert_lock(&host->rrdset_root_index_name, (avl_t *) (&st->avlname));
|
||||
if(result) return rrdset_from_avlname(result);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
|
|||
RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st) {
|
||||
void *result;
|
||||
// fprintf(stderr, "DELETING: %s (name: %s)\n", st->id, st->name);
|
||||
result = (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl *)(&st->avlname));
|
||||
result = (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl_t *)(&st->avlname));
|
||||
if(result) return rrdset_from_avlname(result);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ static inline RRDSET *rrdset_index_find_name(RRDHOST *host, const char *name, ui
|
|||
tmp.hash_name = (hash)?hash:simple_hash(tmp.name);
|
||||
|
||||
// fprintf(stderr, "SEARCHING: %s\n", name);
|
||||
result = avl_search_lock(&host->rrdset_root_index_name, (avl *) (&(tmp.avlname)));
|
||||
result = avl_search_lock(&host->rrdset_root_index_name, (avl_t *) (&(tmp.avlname)));
|
||||
if(result) {
|
||||
RRDSET *st = rrdset_from_avlname(result);
|
||||
if(strcmp(st->magic, RRDSET_MAGIC) != 0)
|
||||
|
@ -744,8 +744,8 @@ RRDSET *rrdset_create_custom(
|
|||
);
|
||||
|
||||
if(st) {
|
||||
memset(&st->avl, 0, sizeof(avl));
|
||||
memset(&st->avlname, 0, sizeof(avl));
|
||||
memset(&st->avl, 0, sizeof(avl_t));
|
||||
memset(&st->avlname, 0, sizeof(avl_t));
|
||||
memset(&st->rrdvar_root_index, 0, sizeof(avl_tree_lock));
|
||||
memset(&st->dimensions_index, 0, sizeof(avl_tree_lock));
|
||||
memset(&st->rrdset_rwlock, 0, sizeof(netdata_rwlock_t));
|
||||
|
|
|
@ -27,7 +27,7 @@ int rrdvar_compare(void* a, void* b) {
|
|||
}
|
||||
|
||||
static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
|
||||
RRDVAR *ret = (RRDVAR *)avl_insert_lock(tree, (avl *)(rv));
|
||||
RRDVAR *ret = (RRDVAR *)avl_insert_lock(tree, (avl_t *)(rv));
|
||||
if(ret != rv)
|
||||
debug(D_VARIABLES, "Request to insert RRDVAR '%s' into index failed. Already exists.", rv->name);
|
||||
|
||||
|
@ -35,7 +35,7 @@ static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
|
|||
}
|
||||
|
||||
static inline RRDVAR *rrdvar_index_del(avl_tree_lock *tree, RRDVAR *rv) {
|
||||
RRDVAR *ret = (RRDVAR *)avl_remove_lock(tree, (avl *)(rv));
|
||||
RRDVAR *ret = (RRDVAR *)avl_remove_lock(tree, (avl_t *)(rv));
|
||||
if(!ret)
|
||||
error("Request to remove RRDVAR '%s' from index failed. Not Found.", rv->name);
|
||||
|
||||
|
@ -47,7 +47,7 @@ static inline RRDVAR *rrdvar_index_find(avl_tree_lock *tree, const char *name, u
|
|||
tmp.name = (char *)name;
|
||||
tmp.hash = (hash)?hash:simple_hash(tmp.name);
|
||||
|
||||
return (RRDVAR *)avl_search_lock(tree, (avl *)&tmp);
|
||||
return (RRDVAR *)avl_search_lock(tree, (avl_t *)&tmp);
|
||||
}
|
||||
|
||||
inline void rrdvar_free(RRDHOST *host, avl_tree_lock *tree, RRDVAR *rv) {
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef enum rrdvar_options {
|
|||
// 2. at each context (RRDFAMILY.rrdvar_root_index)
|
||||
// 3. at each host (RRDHOST.rrdvar_root_index)
|
||||
struct rrdvar {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
char *name;
|
||||
uint32_t hash;
|
||||
|
|
|
@ -243,7 +243,7 @@ static inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char
|
|||
RRDCALC *rc = alarm_max_last_repeat(host, alarm_name,simple_hash(alarm_name));
|
||||
if (!rc) {
|
||||
for(rc = host->alarms; rc ; rc = rc->next) {
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_name, (avl *)rc);
|
||||
RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_name, (avl_t *)rc);
|
||||
if(rdcmp != rc) {
|
||||
error("Cannot insert the alarm index ID using log %s", rc->name);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
/* Search |tree| for an item matching |item|, and return it if found.
|
||||
Otherwise return |NULL|. */
|
||||
avl *avl_search(avl_tree_type *tree, avl *item) {
|
||||
avl *p;
|
||||
avl_t *avl_search(avl_tree_type *tree, avl_t *item) {
|
||||
avl_t *p;
|
||||
|
||||
// assert (tree != NULL && item != NULL);
|
||||
|
||||
|
@ -40,11 +40,11 @@ avl *avl_search(avl_tree_type *tree, avl *item) {
|
|||
If a duplicate item is found in the tree,
|
||||
returns a pointer to the duplicate without inserting |item|.
|
||||
*/
|
||||
avl *avl_insert(avl_tree_type *tree, avl *item) {
|
||||
avl *y, *z; /* Top node to update balance factor, and parent. */
|
||||
avl *p, *q; /* Iterator, and parent. */
|
||||
avl *n; /* Newly inserted node. */
|
||||
avl *w; /* New root of rebalanced subtree. */
|
||||
avl_t *avl_insert(avl_tree_type *tree, avl_t *item) {
|
||||
avl_t *y, *z; /* Top node to update balance factor, and parent. */
|
||||
avl_t *p, *q; /* Iterator, and parent. */
|
||||
avl_t *n; /* Newly inserted node. */
|
||||
avl_t *w; /* New root of rebalanced subtree. */
|
||||
unsigned char dir; /* Direction to descend. */
|
||||
|
||||
unsigned char da[AVL_MAX_HEIGHT]; /* Cached comparison results. */
|
||||
|
@ -52,7 +52,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
|
|||
|
||||
// assert(tree != NULL && item != NULL);
|
||||
|
||||
z = (avl *) &tree->root;
|
||||
z = (avl_t *) &tree->root;
|
||||
y = tree->root;
|
||||
dir = 0;
|
||||
for (q = z, p = y; p != NULL; q = p, p = p->avl_link[dir]) {
|
||||
|
@ -79,7 +79,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
|
|||
p->avl_balance++;
|
||||
|
||||
if (y->avl_balance == -2) {
|
||||
avl *x = y->avl_link[0];
|
||||
avl_t *x = y->avl_link[0];
|
||||
if (x->avl_balance == -1) {
|
||||
w = x;
|
||||
y->avl_link[0] = x->avl_link[1];
|
||||
|
@ -103,7 +103,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
|
|||
}
|
||||
}
|
||||
else if (y->avl_balance == +2) {
|
||||
avl *x = y->avl_link[1];
|
||||
avl_t *x = y->avl_link[1];
|
||||
if (x->avl_balance == +1) {
|
||||
w = x;
|
||||
y->avl_link[1] = x->avl_link[0];
|
||||
|
@ -136,19 +136,19 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
|
|||
|
||||
/* Deletes from |tree| and returns an item matching |item|.
|
||||
Returns a null pointer if no matching item found. */
|
||||
avl *avl_remove(avl_tree_type *tree, avl *item) {
|
||||
avl_t *avl_remove(avl_tree_type *tree, avl_t *item) {
|
||||
/* Stack of nodes. */
|
||||
avl *pa[AVL_MAX_HEIGHT]; /* Nodes. */
|
||||
avl_t *pa[AVL_MAX_HEIGHT]; /* Nodes. */
|
||||
unsigned char da[AVL_MAX_HEIGHT]; /* |avl_link[]| indexes. */
|
||||
int k; /* Stack pointer. */
|
||||
|
||||
avl *p; /* Traverses tree to find node to delete. */
|
||||
avl_t *p; /* Traverses tree to find node to delete. */
|
||||
int cmp; /* Result of comparison between |item| and |p|. */
|
||||
|
||||
// assert (tree != NULL && item != NULL);
|
||||
|
||||
k = 0;
|
||||
p = (avl *) &tree->root;
|
||||
p = (avl_t *) &tree->root;
|
||||
for(cmp = -1; cmp != 0; cmp = tree->compar(item, p)) {
|
||||
unsigned char dir = (unsigned char)(cmp > 0);
|
||||
|
||||
|
@ -164,7 +164,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
|
|||
if (p->avl_link[1] == NULL)
|
||||
pa[k - 1]->avl_link[da[k - 1]] = p->avl_link[0];
|
||||
else {
|
||||
avl *r = p->avl_link[1];
|
||||
avl_t *r = p->avl_link[1];
|
||||
if (r->avl_link[0] == NULL) {
|
||||
r->avl_link[0] = p->avl_link[0];
|
||||
r->avl_balance = p->avl_balance;
|
||||
|
@ -173,7 +173,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
|
|||
pa[k++] = r;
|
||||
}
|
||||
else {
|
||||
avl *s;
|
||||
avl_t *s;
|
||||
int j = k++;
|
||||
|
||||
for (;;) {
|
||||
|
@ -198,15 +198,15 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
|
|||
|
||||
// assert (k > 0);
|
||||
while (--k > 0) {
|
||||
avl *y = pa[k];
|
||||
avl_t *y = pa[k];
|
||||
|
||||
if (da[k] == 0) {
|
||||
y->avl_balance++;
|
||||
if (y->avl_balance == +1) break;
|
||||
else if (y->avl_balance == +2) {
|
||||
avl *x = y->avl_link[1];
|
||||
avl_t *x = y->avl_link[1];
|
||||
if (x->avl_balance == -1) {
|
||||
avl *w;
|
||||
avl_t *w;
|
||||
// assert (x->avl_balance == -1);
|
||||
w = x->avl_link[0];
|
||||
x->avl_link[0] = w->avl_link[1];
|
||||
|
@ -240,9 +240,9 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
|
|||
y->avl_balance--;
|
||||
if (y->avl_balance == -1) break;
|
||||
else if (y->avl_balance == -2) {
|
||||
avl *x = y->avl_link[0];
|
||||
avl_t *x = y->avl_link[0];
|
||||
if (x->avl_balance == +1) {
|
||||
avl *w;
|
||||
avl_t *w;
|
||||
// assert (x->avl_balance == +1);
|
||||
w = x->avl_link[1];
|
||||
x->avl_link[1] = w->avl_link[0];
|
||||
|
@ -284,7 +284,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
|
|||
// ---------------------------
|
||||
// traversing
|
||||
|
||||
int avl_walker(avl *node, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
|
||||
int avl_walker(avl_t *node, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
|
||||
int total = 0, ret = 0;
|
||||
|
||||
if(node->avl_link[0]) {
|
||||
|
@ -383,23 +383,23 @@ void avl_destroy_lock(avl_tree_lock *tree) {
|
|||
#endif /* AVL_WITHOUT_PTHREADS */
|
||||
}
|
||||
|
||||
avl *avl_search_lock(avl_tree_lock *tree, avl *item) {
|
||||
avl_t *avl_search_lock(avl_tree_lock *tree, avl_t *item) {
|
||||
avl_read_lock(tree);
|
||||
avl *ret = avl_search(&tree->avl_tree, item);
|
||||
avl_t *ret = avl_search(&tree->avl_tree, item);
|
||||
avl_unlock(tree);
|
||||
return ret;
|
||||
}
|
||||
|
||||
avl * avl_remove_lock(avl_tree_lock *tree, avl *item) {
|
||||
avl_t * avl_remove_lock(avl_tree_lock *tree, avl_t *item) {
|
||||
avl_write_lock(tree);
|
||||
avl *ret = avl_remove(&tree->avl_tree, item);
|
||||
avl_t *ret = avl_remove(&tree->avl_tree, item);
|
||||
avl_unlock(tree);
|
||||
return ret;
|
||||
}
|
||||
|
||||
avl *avl_insert_lock(avl_tree_lock *tree, avl *item) {
|
||||
avl_t *avl_insert_lock(avl_tree_lock *tree, avl_t *item) {
|
||||
avl_write_lock(tree);
|
||||
avl * ret = avl_insert(&tree->avl_tree, item);
|
||||
avl_t * ret = avl_insert(&tree->avl_tree, item);
|
||||
avl_unlock(tree);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
/* Data structures */
|
||||
|
||||
/* One element of the AVL tree */
|
||||
typedef struct avl {
|
||||
struct avl *avl_link[2]; /* Subtrees. */
|
||||
typedef struct avl_element {
|
||||
struct avl_element *avl_link[2]; /* Subtrees. */
|
||||
signed char avl_balance; /* Balance factor. */
|
||||
} avl;
|
||||
} avl_t;
|
||||
|
||||
/* An AVL tree */
|
||||
typedef struct avl_tree_type {
|
||||
avl *root;
|
||||
avl_t *root;
|
||||
int (*compar)(void *a, void *b);
|
||||
} avl_tree_type;
|
||||
|
||||
|
@ -59,23 +59,23 @@ typedef struct avl_tree_lock {
|
|||
* a is linked directly to the tree, so it has to
|
||||
* be properly allocated by the caller.
|
||||
*/
|
||||
avl *avl_insert_lock(avl_tree_lock *tree, avl *item) NEVERNULL WARNUNUSED;
|
||||
avl *avl_insert(avl_tree_type *tree, avl *item) NEVERNULL WARNUNUSED;
|
||||
avl_t *avl_insert_lock(avl_tree_lock *tree, avl_t *item) NEVERNULL WARNUNUSED;
|
||||
avl_t *avl_insert(avl_tree_type *tree, avl_t *item) NEVERNULL WARNUNUSED;
|
||||
|
||||
/* Remove an element a from the AVL tree t
|
||||
* returns a pointer to the removed element
|
||||
* or NULL if an element equal to a is not found
|
||||
* (equal as returned by t->compar())
|
||||
*/
|
||||
avl *avl_remove_lock(avl_tree_lock *tree, avl *item) WARNUNUSED;
|
||||
avl *avl_remove(avl_tree_type *tree, avl *item) WARNUNUSED;
|
||||
avl_t *avl_remove_lock(avl_tree_lock *tree, avl_t *item) WARNUNUSED;
|
||||
avl_t *avl_remove(avl_tree_type *tree, avl_t *item) WARNUNUSED;
|
||||
|
||||
/* Find the element into the tree that equal to a
|
||||
* (equal as returned by t->compar())
|
||||
* returns NULL is no element is equal to a
|
||||
*/
|
||||
avl *avl_search_lock(avl_tree_lock *tree, avl *item);
|
||||
avl *avl_search(avl_tree_type *tree, avl *item);
|
||||
avl_t *avl_search_lock(avl_tree_lock *tree, avl_t *item);
|
||||
avl_t *avl_search(avl_tree_type *tree, avl_t *item);
|
||||
|
||||
/* Initialize the avl_tree_lock
|
||||
*/
|
||||
|
|
|
@ -123,15 +123,15 @@ static int appconfig_option_compare(void *a, void *b) {
|
|||
else return strcmp(((struct config_option *)a)->name, ((struct config_option *)b)->name);
|
||||
}
|
||||
|
||||
#define appconfig_option_index_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl *)(cv))
|
||||
#define appconfig_option_index_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl *)(cv))
|
||||
#define appconfig_option_index_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl_t *)(cv))
|
||||
#define appconfig_option_index_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl_t *)(cv))
|
||||
|
||||
static struct config_option *appconfig_option_index_find(struct section *co, const char *name, uint32_t hash) {
|
||||
struct config_option tmp;
|
||||
tmp.hash = (hash)?hash:simple_hash(name);
|
||||
tmp.name = (char *)name;
|
||||
|
||||
return (struct config_option *)avl_search_lock(&(co->values_index), (avl *) &tmp);
|
||||
return (struct config_option *)avl_search_lock(&(co->values_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,15 +144,15 @@ int appconfig_section_compare(void *a, void *b) {
|
|||
else return strcmp(((struct section *)a)->name, ((struct section *)b)->name);
|
||||
}
|
||||
|
||||
#define appconfig_index_add(root, cfg) (struct section *)avl_insert_lock(&(root)->index, (avl *)(cfg))
|
||||
#define appconfig_index_del(root, cfg) (struct section *)avl_remove_lock(&(root)->index, (avl *)(cfg))
|
||||
#define appconfig_index_add(root, cfg) (struct section *)avl_insert_lock(&(root)->index, (avl_t *)(cfg))
|
||||
#define appconfig_index_del(root, cfg) (struct section *)avl_remove_lock(&(root)->index, (avl_t *)(cfg))
|
||||
|
||||
static struct section *appconfig_index_find(struct config *root, const char *name, uint32_t hash) {
|
||||
struct section tmp;
|
||||
tmp.hash = (hash)?hash:simple_hash(name);
|
||||
tmp.name = (char *)name;
|
||||
|
||||
return (struct section *)avl_search_lock(&root->index, (avl *) &tmp);
|
||||
return (struct section *)avl_search_lock(&root->index, (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
#define CONFIG_VALUE_CHECKED 0x08 // has been checked if the value is different from the default
|
||||
|
||||
struct config_option {
|
||||
avl avl_node; // the index entry of this entry - this has to be first!
|
||||
avl_t avl_node; // the index entry of this entry - this has to be first!
|
||||
|
||||
uint8_t flags;
|
||||
uint32_t hash; // a simple hash to speed up searching
|
||||
|
@ -124,7 +124,7 @@ struct config_option {
|
|||
};
|
||||
|
||||
struct section {
|
||||
avl avl_node; // the index entry of this section - this has to be first!
|
||||
avl_t avl_node; // the index entry of this section - this has to be first!
|
||||
|
||||
uint32_t hash; // a simple hash to speed up searching
|
||||
// we first compare hashes, and only if the hashes are equal we do string comparisons
|
||||
|
|
|
@ -67,7 +67,7 @@ static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *di
|
|||
tmp.name = (char *)name;
|
||||
|
||||
NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict);
|
||||
return (NAME_VALUE *)avl_search(&(dict->values_index), (avl *) &tmp);
|
||||
return (NAME_VALUE *)avl_search(&(dict->values_index), (avl_t *) &tmp);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -95,7 +95,7 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
|
|||
|
||||
// index it
|
||||
NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict);
|
||||
if(unlikely(avl_insert(&((dict)->values_index), (avl *)(nv)) != (avl *)nv))
|
||||
if(unlikely(avl_insert(&((dict)->values_index), (avl_t *)(nv)) != (avl_t *)nv))
|
||||
error("dictionary: INTERNAL ERROR: duplicate insertion to dictionary.");
|
||||
|
||||
NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict);
|
||||
|
@ -107,7 +107,7 @@ static void dictionary_name_value_destroy_nolock(DICTIONARY *dict, NAME_VALUE *n
|
|||
debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", nv->name);
|
||||
|
||||
NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict);
|
||||
if(unlikely(avl_remove(&(dict->values_index), (avl *)(nv)) != (avl *)nv))
|
||||
if(unlikely(avl_remove(&(dict->values_index), (avl_t *)(nv)) != (avl_t *)nv))
|
||||
error("dictionary: INTERNAL ERROR: dictionary invalid removal of node.");
|
||||
|
||||
NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict);
|
||||
|
@ -258,7 +258,7 @@ int dictionary_del(DICTIONARY *dict, const char *name) {
|
|||
// the dictionary is locked for reading while this happens
|
||||
// do not user other dictionary calls while walking the dictionary - deadlock!
|
||||
|
||||
static int dictionary_walker(avl *a, int (*callback)(void *entry, void *data), void *data) {
|
||||
static int dictionary_walker(avl_t *a, int (*callback)(void *entry, void *data), void *data) {
|
||||
int total = 0, ret = 0;
|
||||
|
||||
if(a->avl_link[0]) {
|
||||
|
@ -293,7 +293,7 @@ int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *data
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int dictionary_walker_name_value(avl *a, int (*callback)(char *name, void *entry, void *data), void *data) {
|
||||
static int dictionary_walker_name_value(avl_t *a, int (*callback)(char *name, void *entry, void *data), void *data) {
|
||||
int total = 0, ret = 0;
|
||||
|
||||
if(a->avl_link[0]) {
|
||||
|
|
|
@ -13,7 +13,7 @@ struct dictionary_stats {
|
|||
};
|
||||
|
||||
typedef struct name_value {
|
||||
avl avl_node; // the index - this has to be first!
|
||||
avl_t avl_node; // the index - this has to be first!
|
||||
|
||||
uint32_t hash; // a simple hash to speed up searching
|
||||
// we first compare hashes, and only if the hashes are equal we do string comparisons
|
||||
|
|
|
@ -32,7 +32,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, c
|
|||
|
||||
inline REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) {
|
||||
debug(D_REGISTRY, "Registry: registry_person_url_index_add('%s', '%s')", p->guid, pu->url->url);
|
||||
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_insert(&(p->person_urls), (avl *)(pu));
|
||||
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_insert(&(p->person_urls), (avl_t *)(pu));
|
||||
if(tpu != pu)
|
||||
error("Registry: registry_person_url_index_add('%s', '%s') already exists as '%s'", p->guid, pu->url->url, tpu->url->url);
|
||||
|
||||
|
@ -41,7 +41,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, RE
|
|||
|
||||
inline REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) {
|
||||
debug(D_REGISTRY, "Registry: registry_person_url_index_del('%s', '%s')", p->guid, pu->url->url);
|
||||
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_remove(&(p->person_urls), (avl *)(pu));
|
||||
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_remove(&(p->person_urls), (avl_t *)(pu));
|
||||
if(!tpu)
|
||||
error("Registry: registry_person_url_index_del('%s', '%s') deleted nothing", p->guid, pu->url->url);
|
||||
else if(tpu != pu)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// for each PERSON-URL pair we keep this
|
||||
struct registry_person_url {
|
||||
avl avl; // binary tree node
|
||||
avl_t avl; // binary tree node
|
||||
|
||||
REGISTRY_URL *url; // de-duplicated URL
|
||||
REGISTRY_MACHINE *machine; // link the MACHINE of this URL
|
||||
|
|
|
@ -13,11 +13,11 @@ int registry_url_compare(void *a, void *b) {
|
|||
}
|
||||
|
||||
inline REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) {
|
||||
return (REGISTRY_URL *)avl_insert(&(registry.registry_urls_root_index), (avl *)(u));
|
||||
return (REGISTRY_URL *)avl_insert(&(registry.registry_urls_root_index), (avl_t *)(u));
|
||||
}
|
||||
|
||||
inline REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) {
|
||||
return (REGISTRY_URL *)avl_remove(&(registry.registry_urls_root_index), (avl *)(u));
|
||||
return (REGISTRY_URL *)avl_remove(&(registry.registry_urls_root_index), (avl_t *)(u));
|
||||
}
|
||||
|
||||
REGISTRY_URL *registry_url_get(const char *url, size_t urllen) {
|
||||
|
@ -33,7 +33,7 @@ REGISTRY_URL *registry_url_get(const char *url, size_t urllen) {
|
|||
strncpyz(n->url, url, n->len);
|
||||
n->hash = simple_hash(n->url);
|
||||
|
||||
REGISTRY_URL *u = (REGISTRY_URL *)avl_search(&(registry.registry_urls_root_index), (avl *)n);
|
||||
REGISTRY_URL *u = (REGISTRY_URL *)avl_search(&(registry.registry_urls_root_index), (avl_t *)n);
|
||||
if(!u) {
|
||||
debug(D_REGISTRY, "Registry: registry_url_get('%s', %zu): allocating %zu bytes", url, urllen, sizeof(REGISTRY_URL) + urllen);
|
||||
u = callocz(1, sizeof(REGISTRY_URL) + urllen); // no need for +1, 1 is already in REGISTRY_URL
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// we store them here and we keep pointers elsewhere
|
||||
|
||||
struct registry_url {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
uint32_t hash; // the index hash
|
||||
|
||||
uint32_t links; // the number of links to this URL - when none is left, we free it
|
||||
|
|
|
@ -62,7 +62,7 @@ uint64_t spawn_enq_cmd(char *command_to_run)
|
|||
{
|
||||
unsigned queue_size;
|
||||
uint64_t serial;
|
||||
avl *avl_ret;
|
||||
avl_t *avl_ret;
|
||||
struct spawn_cmd_info *cmdinfo;
|
||||
|
||||
cmdinfo = create_spawn_cmd(command_to_run);
|
||||
|
@ -79,8 +79,8 @@ uint64_t spawn_enq_cmd(char *command_to_run)
|
|||
cmdinfo->serial = serial; /* No need to take the cmd mutex since it is unreachable at the moment */
|
||||
|
||||
/* enqueue command */
|
||||
avl_ret = avl_insert(&spawn_cmd_queue.cmd_tree, (avl *)cmdinfo);
|
||||
fatal_assert(avl_ret == (avl *)cmdinfo);
|
||||
avl_ret = avl_insert(&spawn_cmd_queue.cmd_tree, (avl_t *)cmdinfo);
|
||||
fatal_assert(avl_ret == (avl_t *)cmdinfo);
|
||||
uv_mutex_unlock(&spawn_cmd_queue.mutex);
|
||||
|
||||
/* wake up event loop */
|
||||
|
@ -93,13 +93,13 @@ uint64_t spawn_enq_cmd(char *command_to_run)
|
|||
*/
|
||||
void spawn_wait_cmd(uint64_t serial, int *exit_status, time_t *exec_run_timestamp)
|
||||
{
|
||||
avl *avl_ret;
|
||||
avl_t *avl_ret;
|
||||
struct spawn_cmd_info tmp, *cmdinfo;
|
||||
|
||||
tmp.serial = serial;
|
||||
|
||||
uv_mutex_lock(&spawn_cmd_queue.mutex);
|
||||
avl_ret = avl_search(&spawn_cmd_queue.cmd_tree, (avl *)&tmp);
|
||||
avl_ret = avl_search(&spawn_cmd_queue.cmd_tree, (avl_t *)&tmp);
|
||||
uv_mutex_unlock(&spawn_cmd_queue.mutex);
|
||||
|
||||
fatal_assert(avl_ret); /* Could be NULL if more than 1 threads wait for the command */
|
||||
|
@ -122,13 +122,13 @@ void spawn_wait_cmd(uint64_t serial, int *exit_status, time_t *exec_run_timestam
|
|||
void spawn_deq_cmd(struct spawn_cmd_info *cmdinfo)
|
||||
{
|
||||
unsigned queue_size;
|
||||
avl *avl_ret;
|
||||
avl_t *avl_ret;
|
||||
|
||||
uv_mutex_lock(&spawn_cmd_queue.mutex);
|
||||
queue_size = spawn_cmd_queue.size;
|
||||
fatal_assert(queue_size);
|
||||
/* dequeue command */
|
||||
avl_ret = avl_remove(&spawn_cmd_queue.cmd_tree, (avl *)cmdinfo);
|
||||
avl_ret = avl_remove(&spawn_cmd_queue.cmd_tree, (avl_t *)cmdinfo);
|
||||
fatal_assert(avl_ret);
|
||||
|
||||
spawn_cmd_queue.size = queue_size - 1;
|
||||
|
|
|
@ -42,7 +42,7 @@ struct spawn_prot_header {
|
|||
#define SPAWN_CMD_DONE 0x00000008
|
||||
|
||||
struct spawn_cmd_info {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
/* concurrency control per command */
|
||||
uv_mutex_t mutex;
|
||||
|
|
|
@ -16,7 +16,7 @@ static char prot_buffer[MAX_COMMAND_LENGTH];
|
|||
static unsigned prot_buffer_len = 0;
|
||||
|
||||
struct spawn_execution_info {
|
||||
avl avl;
|
||||
avl_t avl;
|
||||
|
||||
void *handle;
|
||||
int exit_status;
|
||||
|
@ -106,7 +106,7 @@ static void wait_children(void *arg)
|
|||
{
|
||||
siginfo_t i;
|
||||
struct spawn_execution_info tmp, *exec_info;
|
||||
avl *ret_avl;
|
||||
avl_t *ret_avl;
|
||||
|
||||
(void)arg;
|
||||
while (!server_shutdown) {
|
||||
|
@ -133,7 +133,7 @@ static void wait_children(void *arg)
|
|||
#endif
|
||||
fatal_assert(CLD_EXITED == i.si_code);
|
||||
tmp.pid = (pid_t)i.si_pid;
|
||||
while (NULL == (ret_avl = avl_remove_lock(&spawn_outstanding_exec_tree, (avl *)&tmp))) {
|
||||
while (NULL == (ret_avl = avl_remove_lock(&spawn_outstanding_exec_tree, (avl_t *)&tmp))) {
|
||||
fprintf(stderr,
|
||||
"SPAWN: race condition detected, waiting for child process %d to be indexed.\n",
|
||||
(int)tmp.pid);
|
||||
|
@ -153,7 +153,7 @@ void spawn_protocol_execute_command(void *handle, char *command_to_run, uint16_t
|
|||
{
|
||||
uv_buf_t writebuf[2];
|
||||
int ret;
|
||||
avl *avl_ret;
|
||||
avl_t *avl_ret;
|
||||
struct spawn_execution_info *exec_info;
|
||||
struct write_context *write_ctx;
|
||||
|
||||
|
@ -174,8 +174,8 @@ void spawn_protocol_execute_command(void *handle, char *command_to_run, uint16_t
|
|||
exec_info = mallocz(sizeof(*exec_info));
|
||||
exec_info->handle = handle;
|
||||
exec_info->pid = write_ctx->spawn_result.exec_pid;
|
||||
avl_ret = avl_insert_lock(&spawn_outstanding_exec_tree, (avl *)exec_info);
|
||||
fatal_assert(avl_ret == (avl *)exec_info);
|
||||
avl_ret = avl_insert_lock(&spawn_outstanding_exec_tree, (avl_t *)exec_info);
|
||||
fatal_assert(avl_ret == (avl_t *)exec_info);
|
||||
|
||||
/* wake up the thread that blocks waiting for processes to exit */
|
||||
uv_mutex_lock(&wait_children_mutex);
|
||||
|
|
Loading…
Add table
Reference in a new issue