processes: Reduce procstat entry 'age' limit
authorPavel Rochnyack <pavel2000@ngs.ru>
Wed, 19 Dec 2018 13:44:25 +0000 (20:44 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Wed, 19 Dec 2018 13:44:25 +0000 (20:44 +0700)
The 'age' value can grow only when process terminated.

There is no sence to wait 10 read cycles for process rebirth.

Theoretically, this reduces probability for process data takeover by
another process with same pid.

Issue: #3026

src/processes.c

index 171dde9..2e3b927 100644 (file)
@@ -216,7 +216,7 @@ typedef struct process_entry_s {
 
 typedef struct procstat_entry_s {
   unsigned long id;
-  unsigned long age;
+  unsigned char age;
 
   derive_t vmem_minflt_counter;
   derive_t vmem_majflt_counter;
@@ -617,7 +617,7 @@ static void ps_list_reset(void) {
     pse_prev = NULL;
     pse = ps->instances;
     while (pse != NULL) {
-      if (pse->age > 10) {
+      if (pse->age > 0) {
         DEBUG("Removing this procstat entry cause it's too old: "
               "id = %lu; name = %s;",
               pse->id, ps->name);
@@ -632,7 +632,7 @@ static void ps_list_reset(void) {
           pse = pse_prev->next;
         }
       } else {
-        pse->age++;
+        pse->age = 1;
         pse_prev = pse;
         pse = pse->next;
       }