From a4417937ca023bb2c9151a139d7d1bcee0541dd9 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 26 Dec 2013 14:12:30 +0100 Subject: [PATCH] store: Don't look up services from hierarchical hosts. We don't have any concept of service inheritance (yet?). Also, I'm not sure if this would ever make sense in general. This might be a query option, though. --- src/core/store.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/store.c b/src/core/store.c index e9e0979..ed5b7ce 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -1,6 +1,6 @@ /* * SysDB - src/core/store.c - * Copyright (C) 2012 Sebastian 'tokkee' Harl + * Copyright (C) 2012-2013 Sebastian 'tokkee' Harl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -224,6 +224,10 @@ sdb_store_lookup_in_list(sdb_llist_t *l, int type, const char *name) return sobj; } + /* don't lookups non-host types from hierarchical hosts */ + if ((type != SDB_HOST) && (sobj->type == SDB_HOST)) + continue; + sobj = sdb_store_lookup_in_list(sobj->children, type, name); if (sobj) { sdb_llist_iter_destroy(iter); @@ -308,13 +312,15 @@ store_obj(int parent_type, const char *parent_name, parent_list = parent->children; } - /* TODO: only look into direct children? */ if (type == SDB_HOST) /* make sure that each host is unique */ old = STORE_OBJ(sdb_store_lookup_in_list(obj_list, type, name)); else if (type == SDB_ATTRIBUTE) + /* look into attributes of this host */ old = STORE_OBJ(sdb_llist_search_by_name(parent_list, name)); else + /* look into services assigned to this host (sdb_store_lookup_in_list + * does not look up services from hierarchical hosts) */ old = STORE_OBJ(sdb_store_lookup_in_list(parent_list, type, name)); if (old) { -- 2.30.2