diff options
Diffstat (limited to 'src/plugin_tc.c')
-rw-r--r--[-rwxr-xr-x] | src/plugin_tc.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/plugin_tc.c b/src/plugin_tc.c index f02b70788..2c7a55cee 100755..100644 --- 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; } - |