summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ef3a4a9)
raw | patch | inline | side by side (parent: ef3a4a9)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 13 Aug 2015 17:02:14 +0000 (19:02 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 13 Aug 2015 17:02:14 +0000 (19:02 +0200) |
This decision should be made on a higher level.
src/core/store.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index 16d389c1ab5b535da6b8562256384470fd21e6da..be8f9fa259406af1e31a2783560da81ca21776de 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
* private helper functions
*/
-static sdb_host_t *
-lookup_host(sdb_store_t *st, const char *name, bool canonicalize)
-{
- sdb_host_t *host;
- char *cname;
-
- assert(name);
- if (! canonicalize)
- return HOST(sdb_avltree_lookup(st->hosts, name));
-
- cname = strdup(name);
- cname = sdb_plugin_cname(cname);
- if (! cname) {
- sdb_log(SDB_LOG_ERR, "store: strdup failed");
- return NULL;
- }
-
- host = HOST(sdb_avltree_lookup(st->hosts, cname));
- free(cname);
- return host;
-} /* lookup_host */
-
static int
record_backend(sdb_store_obj_t *obj)
{
return -1;
pthread_rwlock_wrlock(&st->host_lock);
- host = lookup_host(st, hostname, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(st->hosts, hostname));
attrs = get_host_children(host, SDB_ATTRIBUTE);
if (! attrs) {
sdb_log(SDB_LOG_ERR, "store: Failed to store attribute '%s' - "
return -1;
pthread_rwlock_wrlock(&st->host_lock);
- host = lookup_host(st, hostname, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(st->hosts, hostname));
services = get_host_children(host, SDB_SERVICE);
sdb_object_deref(SDB_OBJ(host));
if (! services) {
return -1;
pthread_rwlock_wrlock(&st->host_lock);
- host = lookup_host(st, hostname, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(st->hosts, hostname));
services = get_host_children(host, SDB_SERVICE);
if (! services) {
sdb_log(SDB_LOG_ERR, "store: Failed to store service '%s' - "
return -1;
pthread_rwlock_wrlock(&st->host_lock);
- host = lookup_host(st, hostname, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(st->hosts, hostname));
metrics = get_host_children(host, SDB_METRIC);
sdb_object_deref(SDB_OBJ(host));
if (! metrics) {
}
pthread_rwlock_wrlock(&st->host_lock);
- host = lookup_host(st, hostname, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(st->hosts, hostname));
metrics = get_host_children(host, SDB_METRIC);
if (! metrics) {
sdb_log(SDB_LOG_ERR, "store: Failed to store metric '%s' - "
if ((! store) || (! name))
return NULL;
- host = lookup_host(store, name, /* canonicalize = */ 0);
+ host = HOST(sdb_avltree_lookup(store->hosts, name));
if (! host)
return NULL;
return -1;
pthread_rwlock_rdlock(&store->host_lock);
- host = lookup_host(store, hostname, /* canonicalize = */ 1);
+ host = HOST(sdb_avltree_lookup(store->hosts, hostname));
metrics = get_host_children(host, SDB_METRIC);
sdb_object_deref(SDB_OBJ(host));
if (! metrics) {