]> arthur.barton.de Git - netdata.git/commitdiff
Merge pull request #1031 from ktsaou/master
authorCosta Tsaousis <costa@tsaousis.gr>
Tue, 27 Sep 2016 20:41:12 +0000 (23:41 +0300)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2016 20:41:12 +0000 (23:41 +0300)
more alpine compatibility fixes

src/plugin_proc.c
src/plugins_d.c
src/popen.c
src/rrd.c
src/sys_fs_cgroup.c

index 3c57b66bb72b8bf3f018ffcbc34ff19cc91dae01..a50a2251463bc5b49a73398292669348798cee79 100644 (file)
@@ -63,7 +63,7 @@ void *proc_main(void *ptr)
     unsigned long long sunext = (time(NULL) - (time(NULL) % rrd_update_every) + rrd_update_every) * 1000000ULL;
     unsigned long long sunow;
 
-    for(;1;) {
+    for(;;) {
         if(unlikely(netdata_exit)) break;
 
         // delay until it is our time to run
@@ -241,6 +241,8 @@ void *proc_main(void *ptr)
         }
     }
 
+    info("PROC thread exiting");
+
     pthread_exit(NULL);
     return NULL;
 }
index 55ccd544389f092abe849625d51487a373eb03e6..0030e22167ddaa5f69f9a7f71ac72689f8faf100 100644 (file)
@@ -109,7 +109,7 @@ void *pluginsd_worker_thread(void *arg)
 
     size_t count = 0;
 
-    while(likely(1)) {
+    for(;;) {
         if(unlikely(netdata_exit)) break;
 
         FILE *fp = mypopen(cd->cmd, &cd->pid);
@@ -380,16 +380,9 @@ void *pluginsd_worker_thread(void *arg)
 
         // get the return code
         int code = mypclose(fp, cd->pid);
-
-        if(netdata_exit) {
-            cd->pid = 0;
-            cd->enabled = 0;
-            cd->obsolete = 1;
-            pthread_exit(NULL);
-            return NULL;
-        }
-
-        if(code != 0) {
+        
+        if(unlikely(netdata_exit)) break;
+        else if(code != 0) {
             // the plugin reports failure
 
             if(likely(!cd->successful_collections)) {
@@ -430,10 +423,11 @@ void *pluginsd_worker_thread(void *arg)
         }
         cd->pid = 0;
 
-        if(unlikely(!cd->enabled))
-            break;
+        if(unlikely(!cd->enabled)) break;
     }
 
+    info("PLUGINSD: '%s' thread exiting", cd->fullfilename);
+
     cd->obsolete = 1;
     pthread_exit(NULL);
     return NULL;
@@ -462,7 +456,7 @@ void *pluginsd_main(void *ptr) {
 
     if(scan_frequency < 1) scan_frequency = 1;
 
-    while(likely(1)) {
+    for(;;) {
         if(unlikely(netdata_exit)) break;
 
         dir = opendir(dir_name);
@@ -542,6 +536,8 @@ void *pluginsd_main(void *ptr) {
         sleep((unsigned int) scan_frequency);
     }
 
+    info("PLUGINS.D thread exiting");
+
     pthread_exit(NULL);
     return NULL;
 }
index 193efc0f36b27e42f70ed7026845312cba5c8fbb..ad8d7596f5ea9383ea3584e9f9f57e71ab101fa8 100644 (file)
@@ -147,6 +147,13 @@ int mypclose(FILE *fp, pid_t pid) {
     debug(D_EXIT, "Request to mypclose() on pid %d", pid);
 
     /*mypopen_del(fp);*/
+
+    // close the pipe fd
+    // this is required in musl
+    // without it the childs do not exit
+    close(fileno(fp));
+
+    // close the pipe file pointer
     fclose(fp);
 
     siginfo_t info;
index 59b0c9988a9354ed85a116581dce4d2b3a9ab455..14fbbaf638bfcd5ffe8e788ebbd3c10e8f17d5b1 100644 (file)
--- a/src/rrd.c
+++ b/src/rrd.c
@@ -1387,8 +1387,10 @@ unsigned long long rrdset_done(RRDSET *st)
                     break;
             }
 
-            if(unlikely(!store_this_entry))
+            if(unlikely(!store_this_entry)) {
+                rd->values[st->current_entry] = pack_storage_number(0, SN_NOT_EXISTS);
                 continue;
+            }
 
             if(likely(rd->updated && rd->counter > 1 && iterations < st->gap_when_lost_iterations_above)) {
                 rd->values[st->current_entry] = pack_storage_number(new_value, storage_flags );
index 0ffd55e21cef17b14491fd277213d3a771be7830..010af824dbe753f5088558c22e159e8d2b9d99dc 100644 (file)
@@ -1326,7 +1326,7 @@ int do_sys_fs_cgroup(int update_every, unsigned long long dt) {
 
 void *cgroups_main(void *ptr)
 {
-    if(ptr) { ; }
+    (void)ptr;
 
     info("CGROUP Plugin thread created with task id %d", gettid());
 
@@ -1351,7 +1351,7 @@ void *cgroups_main(void *ptr)
 
     RRDSET *stcpu_thread = NULL;
 
-    for(;1;) {
+    for(;;) {
         if(unlikely(netdata_exit)) break;
 
         // delay until it is our time to run
@@ -1396,6 +1396,8 @@ void *cgroups_main(void *ptr)
         }
     }
 
+    info("CGROUP thread exiting");
+
     pthread_exit(NULL);
     return NULL;
 }