]> arthur.barton.de Git - netdata.git/commitdiff
fixed a memory leak in badges; allow dimensions with space to be found; allow dimensi...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 6 Jun 2016 20:23:10 +0000 (23:23 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Mon, 6 Jun 2016 20:23:10 +0000 (23:23 +0300)
src/rrd.h
src/rrd2json.c
src/web_client.c

index c97fe7217a4d76db2c1ae173571f7697d9a8acc0..83ab35b69938cebbfebb0316811a58ff2a65e50f 100644 (file)
--- a/src/rrd.h
+++ b/src/rrd.h
@@ -114,6 +114,9 @@ struct rrddim {
                                                                                                        // instead of strcmp() every item in the binary index
                                                                                                        // we first compare the hashes
 
+       // FIXME
+       // we need the hash_name too!
+
        uint32_t flags;
 
        char cache_filename[FILENAME_MAX+1];                    // the filename we load/save from/to this set
index 7735d56fb598e8d229e118a0c61f93bffe049f62..4b5873cf033f7e2fd743a1db67e6a77f51f0fcaa 100644 (file)
@@ -374,12 +374,14 @@ void rrdr_disable_not_selected_dimensions(RRDR *r, const char *dims)
        for(c = 0, d = r->st->dimensions; d ;c++, d = d->next)
                r->od[c] |= RRDR_HIDDEN;
 
-       while(o && *o && (tok = mystrsep(&o, ", |"))) {
+       while(o && *o && (tok = mystrsep(&o, ",|"))) {
                if(!*tok) continue;
+               
+               uint32_t hash = simple_hash(tok);
 
                // find it and enable it
                for(c = 0, d = r->st->dimensions; d ;c++, d = d->next) {
-                       if(!strcmp(d->name, tok)) {
+                       if(unlikely((hash == d->hash && !strcmp(d->id, tok)) || !strcmp(d->name, tok))) {
                                r->od[c] &= ~RRDR_HIDDEN;
 
                                // since the user needs this dimension
index a4b460dd8651ff162c5a88a5ef23bdb4bf33838d..30fdf3851f4b322d28e84967435a1a5dfe840227 100644 (file)
@@ -737,7 +737,9 @@ int web_client_api_v1_badge(struct web_client *w, char *url) {
 
                if(!strcmp(name, "chart")) chart = value;
                else if(!strcmp(name, "dimension") || !strcmp(name, "dim") || !strcmp(name, "dimensions") || !strcmp(name, "dims")) {
-                       if(!dimensions) dimensions = buffer_create(strlen(value));
+                       if(!dimensions)
+                               dimensions = buffer_create(strlen(value));
+
                        if(dimensions) {
                                buffer_strcat(dimensions, "|");
                                buffer_strcat(dimensions, value);
@@ -845,10 +847,10 @@ int web_client_api_v1_badge(struct web_client *w, char *url) {
 
        // render the badge
        buffer_svg(w->response.data, label, n * multiply / divide, units, label_color, value_color, value_is_null, precision);
-       return ret;
 
 cleanup:
-       if(dimensions) buffer_free(dimensions);
+       if(dimensions)
+               buffer_free(dimensions);
        return ret;
 }