@cryptotaxi247 / netdata-1 / commits / 968e6adda

fixed an issue where certain proc files did not read in full

Costa Tsaousis (ktsaou) committed Dec 24, 2015 at 02:46 UTC 968e6adda20685ff222c4648af6fb2da7f4e0865
2 files changed +7 -5
src/proc_net_dev.c
+1 -1
@@ -37,7 +37,7 @@ int do_proc_net_dev(int update_every, unsigned long long dt) {
37 if(do_drops == -1) do_drops = config_get_boolean("plugin:proc:/proc/net/dev", "drops for all interfaces", 1);
38 if(do_fifo == -1) do_fifo = config_get_boolean("plugin:proc:/proc/net/dev", "fifo for all interfaces", 1);
39 if(do_compressed == -1) do_compressed = config_get_boolean("plugin:proc:/proc/net/dev", "compressed packets for all interfaces", 1);
40 - if(do_events == -1) do_events = config_get_boolean("plugin:proc:/proc/net/dev", "frames, collisions, carrier coutners for all interfaces", 1);
40 + if(do_events == -1) do_events = config_get_boolean("plugin:proc:/proc/net/dev", "frames, collisions, carrier counters for all interfaces", 1);
41
42 uint32_t lines = procfile_lines(ff), l;
43 uint32_t words;
src/procfile.c
+6 -4
@@ -235,11 +235,14 @@ cleanup:
235 procfile *procfile_readall(procfile *ff) {
236 debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
237
238 - ssize_t s = 0, r = ff->size, x = ff->size;
238 + ssize_t s, r = 1, x = ff->size;
239 ff->len = 0;
240
241 - while(likely(r == x)) {
242 - if(s) {
241 + while(likely(r > 0)) {
242 + s = ff->len;
243 + x = ff->size - s;
244 +
245 + if(!x) {
246 debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", ff->filename);
247
248 procfile *new = realloc(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
@@ -262,7 +265,6 @@ procfile *procfile_readall(procfile *ff) {
265 }
266
267 ff->len += r;
265 - s = ff->len;
268 }
269
270 debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);