Code

store: Let store_metric() accept non-NULL but empty metric-store.
authorSebastian Harl <sh@tokkee.org>
Sat, 10 Jan 2015 12:33:13 +0000 (13:33 +0100)
committerSebastian Harl <sh@tokkee.org>
Sat, 10 Jan 2015 12:33:13 +0000 (13:33 +0100)
src/core/store.c

index 25691dc36839d6b38f9ea2061fcbf0f23378a4ba..98b3a96d28ee6186518ba1f9bd5a16ef2a84e22f 100644 (file)
@@ -681,8 +681,13 @@ sdb_store_metric(const char *hostname, const char *name,
 
        if ((! hostname) || (! name))
                return -1;
-       if (store && ((! store->type) || (! store->id)))
-               return -1;
+
+       if (store) {
+               if ((store->type != NULL) != (store->id != NULL))
+                       return -1;
+               else if (! store->type)
+                       store = NULL;
+       }
 
        pthread_rwlock_wrlock(&host_lock);
        host = lookup_host(hostname, /* canonicalize = */ 1);