diff options
Diffstat (limited to 'linux/LinuxProcessList.c')
-rw-r--r-- | linux/LinuxProcessList.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index b12a415b..c6fd205a 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -189,6 +189,13 @@ static void LinuxProcessList_updateCPUcount(ProcessList* super, FILE* stream) { } } +static void LinuxProcessList_updateTime(LinuxProcessList* this) { + ProcessList* pl = &(this->super); + + gettimeofday(&pl->timestamp, NULL); + pl->timestampMs = (uint64_t)&pl->timestamp.tv_sec * 1000 + (uint64_t)pl->timestamp.tv_usec / 1000; +} + ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) { LinuxProcessList* this = xCalloc(1, sizeof(LinuxProcessList)); ProcessList* pl = &(this->super); @@ -1968,6 +1975,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { LinuxProcessList* this = (LinuxProcessList*) super; const Settings* settings = super->settings; + LinuxProcessList_updateTime(this); LinuxProcessList_scanMemoryInfo(super); LinuxProcessList_scanHugePages(this); LinuxProcessList_scanZfsArcstats(this); @@ -1989,10 +1997,6 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { return; } - struct timeval tv; - gettimeofday(&tv, NULL); - unsigned long long now = tv.tv_sec * 1000ULL + tv.tv_usec / 1000ULL; - /* PROCDIR is an absolute path */ assert(PROCDIR[0] == '/'); #ifdef HAVE_OPENAT @@ -2001,5 +2005,5 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) { openat_arg_t rootFd = ""; #endif - LinuxProcessList_recurseProcTree(this, rootFd, PROCDIR, NULL, period, now); + LinuxProcessList_recurseProcTree(this, rootFd, PROCDIR, NULL, period, super->timestampMs); } |