@cryptotaxi247 / netdata-1 / commits / 62be86704

nasty bug: char = -1; then char == -1 gives false; fixes #849

Costa Tsaousis (ktsaou) committed Sep 10, 2016 at 18:13 UTC 62be86704dcbd89797d48bc3ec6daa7e277bfe6c
1 file changed +20 -8
src/plugin_tc.c
+20 -8
@@ -216,19 +216,20 @@ static inline void tc_device_commit(struct tc_device *d) {
216 }
217 }
218
219 - // debugging:
219 + // debugging only
220 /*
221 - for ( c = d->classes ; c ; c = c->next) {
222 - if(c->isleaf && c->hasparent) debug(D_TC_LOOP, "TC: Device %s, class %s, OK", d->name, c->id);
223 - else debug(D_TC_LOOP, "TC: Device %s, class %s, IGNORE (isleaf: %d, hasparent: %d, parent: %s)", d->name, c->id, c->isleaf, c->hasparent, c->parentid);
221 + if(unlikely(debug_flags & D_TC_LOOP)) {
222 + for(c = d->classes ; c ; c = c->next) {
223 + if(c->isleaf && c->hasparent) debug(D_TC_LOOP, "TC: Device '%s', class %s, OK", d->name, c->id);
224 + else debug(D_TC_LOOP, "TC: Device '%s', class %s, IGNORE (isleaf: %d, hasparent: %d, parent: %s)", d->name?d->name:d->id, c->id, c->isleaf, c->hasparent, c->parentid?c->parentid:"(unset)");
225 + }
226 }
227 */
228
229 // we need at least a class
230 for(c = d->classes ; c ; c = c->next) {
231 // debug(D_TC_LOOP, "TC: Device '%s', class '%s', isLeaf=%d, HasParent=%d, Seen=%d", d->name?d->name:d->id, c->name?c->name:c->id, c->isleaf, c->hasparent, c->seen);
230 - if(!c->updated) continue;
231 - if(c->isleaf && c->hasparent) {
232 + if(unlikely(c->updated && c->isleaf && c->hasparent)) {
233 active_classes++;
234 bytes_sum += c->bytes;
235 packets_sum += c->packets;
@@ -242,7 +243,7 @@ static inline void tc_device_commit(struct tc_device *d) {
243 return;
244 }
245
245 - if(unlikely(d->enabled == -1)) {
246 + if(unlikely(d->enabled == (char)-1)) {
247 char var_name[CONFIG_MAX_NAME + 1];
248 snprintfz(var_name, CONFIG_MAX_NAME, "qos for %s", d->id);
249 d->enabled = config_get_boolean_ondemand("plugin:tc", var_name, enable_new_interfaces);
@@ -257,6 +258,17 @@ static inline void tc_device_commit(struct tc_device *d) {
258 d->enabled_dropped = config_get_boolean_ondemand("plugin:tc", var_name, enable_dropped);
259 }
260
261 + debug(D_TC_LOOP, "TC: evaluating TC device '%s'. enabled = %d/%d (bytes: %d/%d, packets: %d/%d, dropped: %d/%d), classes = %d (bytes = %llu, packets = %llu, dropped = %llu).",
262 + d->name?d->name:d->id,
263 + d->enabled, enable_new_interfaces,
264 + d->enabled_bytes, enable_bytes,
265 + d->enabled_packets, enable_packets,
266 + d->enabled_dropped, enable_dropped,
267 + active_classes,
268 + bytes_sum,
269 + packets_sum,
270 + dropped_sum);
271 +
272 if(likely(d->enabled)) {
273 // --------------------------------------------------------------------
274 // bytes
@@ -475,7 +487,7 @@ static inline struct tc_device *tc_device_create(char *id)
487
488 d->id = strdupz(id);
489 d->hash = simple_hash(d->id);
478 - d->enabled = -1;
490 + d->enabled = (char)-1;
491
492 avl_init(&d->classes_index, tc_class_compare);
493 tc_device_index_add(d);