]> arthur.barton.de Git - netdata.git/blobdiff - src/web_client.c
dns_query_time plugin: replace "." with "_" in dimensions
[netdata.git] / src / web_client.c
index 4fe207ddbd2936007d87294175c86457204213cc..b5b25899f624f30b97c3667ec4b53444e93c7cd8 100644 (file)
@@ -25,6 +25,8 @@ static inline int web_client_crock_socket(struct web_client *w) {
             return -1;
         }
     }
+#else
+    (void)w;
 #endif /* TCP_CORK */
 
     return 0;
@@ -40,6 +42,8 @@ static inline int web_client_uncrock_socket(struct web_client *w) {
             return -1;
         }
     }
+#else
+    (void)w;
 #endif /* TCP_CORK */
 
     return 0;
@@ -239,7 +243,7 @@ uid_t web_files_uid(void) {
     static uid_t owner_uid = 0;
 
     if(unlikely(!web_owner)) {
-        web_owner = config_get(CONFIG_SECTION_API, "web files owner", config_get(CONFIG_SECTION_GLOBAL, "run as user", ""));
+        web_owner = config_get(CONFIG_SECTION_WEB, "web files owner", config_get(CONFIG_SECTION_GLOBAL, "run as user", ""));
         if(!web_owner || !*web_owner)
             owner_uid = geteuid();
         else {
@@ -266,7 +270,7 @@ gid_t web_files_gid(void) {
     static gid_t owner_gid = 0;
 
     if(unlikely(!web_group)) {
-        web_group = config_get(CONFIG_SECTION_API, "web files group", config_get(CONFIG_SECTION_API, "web files owner", ""));
+        web_group = config_get(CONFIG_SECTION_WEB, "web files group", config_get(CONFIG_SECTION_WEB, "web files owner", ""));
         if(!web_group || !*web_group)
             owner_gid = getegid();
         else {
@@ -1034,19 +1038,10 @@ static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, ch
 
         uint32_t hash = simple_hash(tok);
 
-        if(unlikely(hash == hash_localhost && !strcmp(tok, "localhost")))
-            return web_client_process_url(localhost, w, url);
+        host = rrdhost_find_by_hostname(tok, hash);
+        if(!host) host = rrdhost_find_by_guid(tok, hash);
 
-        rrd_rdlock();
-        RRDHOST *h;
-        rrdhost_foreach_read(h) {
-            if(unlikely((hash == h->hash_hostname && !strcmp(tok, h->hostname)) ||
-                        (hash == h->hash_machine_guid && !strcmp(tok, h->machine_guid)))) {
-                rrd_unlock();
-                return web_client_process_url(h, w, url);
-            }
-        }
-        rrd_unlock();
+        if(host) return web_client_process_url(host, w, url);
     }
 
     buffer_flush(w->response.data);