From 30b94862648cdbf4f537337d2e2f01c369a9dee9 Mon Sep 17 00:00:00 2001 From: Lennart Weller Date: Thu, 21 Apr 2016 14:27:29 +0200 Subject: Imported Upstream version 1.1.0 --- src/plugin_tc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) mode change 100755 => 100644 src/plugin_tc.c (limited to 'src/plugin_tc.c') diff --git a/src/plugin_tc.c b/src/plugin_tc.c old mode 100755 new mode 100644 index f02b70788..2c7a55cee --- a/src/plugin_tc.c +++ b/src/plugin_tc.c @@ -15,6 +15,7 @@ #include "popen.h" #include "plugin_tc.h" #include "main.h" +#include "../config.h" #define RRD_TYPE_TC "tc" #define RRD_TYPE_TC_LEN strlen(RRD_TYPE_TC) @@ -346,11 +347,15 @@ static struct tc_device *tc_device_create(char *id) d->classes_index.root = NULL; d->classes_index.compar = tc_class_compare; + + int lock; #ifdef AVL_LOCK_WITH_MUTEX - pthread_mutex_init(&d->classes_index.mutex, NULL); + lock = pthread_mutex_init(&d->classes_index.mutex, NULL); #else - pthread_rwlock_init(&d->classes_index.rwlock, NULL); + lock = pthread_rwlock_init(&d->classes_index.rwlock, NULL); #endif + if(lock != 0) + fatal("Failed to initialize plugin_tc mutex/rwlock, return code %d.", lock); tc_device_index_add(d); @@ -713,7 +718,8 @@ void *tc_main(void *ptr) // debug(D_TC_LOOP, "IGNORED line"); //} } - mypclose(fp, tc_child_pid); + // fgets() failed or loop broke + int code = mypclose(fp, tc_child_pid); tc_child_pid = 0; if(device) { @@ -728,10 +734,19 @@ void *tc_main(void *ptr) return NULL; } + if(code == 1 || code == 127) { + // 1 = DISABLE + // 127 = cannot even run it + error("TC: tc-qos-helper.sh exited with code %d. Disabling it.", code); + + tc_device_free_all(); + pthread_exit(NULL); + return NULL; + } + sleep((unsigned int) rrd_update_every); } pthread_exit(NULL); return NULL; } - -- cgit v1.2.3