]> arthur.barton.de Git - netdata.git/commitdiff
fixed an issue where certain proc files did not read in full
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 24 Dec 2015 00:46:58 +0000 (02:46 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 24 Dec 2015 00:46:58 +0000 (02:46 +0200)
src/proc_net_dev.c
src/procfile.c

index 4601958091a93bca60f6a3299f4fb58eb5a77e32..5d9fc59fa06bc71023229809cbd6b3b05fe2c6a0 100755 (executable)
@@ -37,7 +37,7 @@ int do_proc_net_dev(int update_every, unsigned long long dt) {
        if(do_drops == -1)              do_drops                = config_get_boolean("plugin:proc:/proc/net/dev", "drops for all interfaces", 1);
        if(do_fifo == -1)               do_fifo                 = config_get_boolean("plugin:proc:/proc/net/dev", "fifo for all interfaces", 1);
        if(do_compressed == -1) do_compressed   = config_get_boolean("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", 1);
-       if(do_events == -1)             do_events               = config_get_boolean("plugin:proc:/proc/net/dev", "frames, collisions, carrier coutners for all interfaces", 1);
+       if(do_events == -1)             do_events               = config_get_boolean("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", 1);
 
        uint32_t lines = procfile_lines(ff), l;
        uint32_t words;
index b06b5adc770697e38fcb597e28dfed6faedf952b..5bd1b10e634298a1d057fee2027a5236ed651d79 100755 (executable)
@@ -235,11 +235,14 @@ cleanup:
 procfile *procfile_readall(procfile *ff) {
        debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
 
-       ssize_t s = 0, r = ff->size, x = ff->size;
+       ssize_t s, r = 1, x = ff->size;
        ff->len = 0;
 
-       while(likely(r == x)) {
-               if(s) {
+       while(likely(r > 0)) {
+               s = ff->len;
+               x = ff->size - s;
+
+               if(!x) {
                        debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", ff->filename);
 
                        procfile *new = realloc(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
@@ -262,7 +265,6 @@ procfile *procfile_readall(procfile *ff) {
                }
 
                ff->len += r;
-               s = ff->len;
        }
 
        debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);