@cryptotaxi247 / netdata-1 / commits / 6d59c534d

convert sys_fs_cgroup to heartbeat API

Signed-off-by: Rémi Lefèvre <remi.lefevre@parrot.com>

Rémi Lefèvre committed Dec 13, 2016 at 19:18 UTC 6d59c534d151a60708bb95692e3adf48a8c32ce8
1 file changed +7 -11
src/sys_fs_cgroup.c
+7 -11
@@ -2079,24 +2079,20 @@ void *cgroups_main(void *ptr) {
2079
2080 RRDSET *stcpu_thread = NULL;
2081
2082 + heartbeat_t hb;
2083 + heartbeat_init(&hb);
2084 usec_t step = cgroup_update_every * USEC_PER_SEC;
2083 - usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_next = 0;
2085 + usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_dt = 0;
2086 for(;;) {
2085 - usec_t now = now_monotonic_usec();
2086 - usec_t next = now - (now % step) + step;
2087 -
2088 - while(now < next) {
2089 - sleep_usec(next - now);
2090 - now = now_monotonic_usec();
2091 - }
2092 -
2087 + usec_t hb_dt = heartbeat_next(&hb, step);
2088 if(unlikely(netdata_exit)) break;
2089
2090 // BEGIN -- the job to be done
2091
2097 - if(unlikely(now >= find_next)) {
2092 + find_dt += hb_dt;
2093 + if(unlikely(find_dt >= find_every)) {
2094 find_all_cgroups();
2099 - find_next = now + find_every;
2095 + find_dt = 0;
2096 }
2097
2098 read_all_cgroups(cgroup_root);