From 6fadf3e159c371f00ccd6261a9f01fc81fad375e Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Wed, 15 Dec 2010 01:02:38 +0100 Subject: Top.hs: bug fix We weren't guarding for the case of time lapses between updates being zero, which can be the case if we come back from sleep or the clock is externally modified. --- Plugins/Monitors/Top.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs index 30476ac..7246183 100644 --- a/Plugins/Monitors/Top.hs +++ b/Plugins/Monitors/Top.hs @@ -133,8 +133,10 @@ topProcesses tref scale = do c1 <- getCurrentTime atomicModifyIORef tref $ \(t0, c0) -> let scx = realToFrac (diffUTCTime c1 c0) * scale / 100 + -- c0 and c1 can be equal, for instance, if we come back from sleep + !scx' = if scx > 0 then scx else (scale / 100) ts = M.elems $ combineTimeInfos t0 t1 - nts = map (\(nm, t) -> (nm, min 100 (t / scx))) ts + nts = map (\(nm, t) -> (nm, min 100 (t / scx'))) ts in ((t1, c1), (len, sortTop nts, sortTop mis)) showTimeInfo :: TimeInfo -> Monitor [String] -- cgit v1.2.3