On Tue, Mar 03, 2015 at 03:06:56PM +0100, 'Klaus Aehlig' via ganeti-devel wrote:
...to avoid stateful collectors that are not queried regularly
accumulating thunks.
Signed-off-by: Klaus Aehlig <[email protected]>
---
src/Ganeti/Monitoring/Server.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Ganeti/Monitoring/Server.hs b/src/Ganeti/Monitoring/Server.hs
index 2f34cee..def1e72 100644
--- a/src/Ganeti/Monitoring/Server.hs
+++ b/src/Ganeti/Monitoring/Server.hs
@@ -41,6 +41,7 @@ module Ganeti.Monitoring.Server
) where
import Control.Applicative
+import Control.DeepSeq (force)
import Control.Monad
import Control.Monad.IO.Class
import Data.ByteString.Char8 hiding (map, filter, find)
@@ -251,7 +252,7 @@ collect m collector =
let name = dName collector
existing = Map.lookup name m
new_data <- update existing
- return $ Map.insert name new_data m
+ return $ Map.insert name (force new_data) m
Since we're already in `IO`, just to be really sure we might want to use
`evaluate` to ensure that there are really no thunks, something like
new_data <- ...
new_data_forced <- evaluate . force $ new_data
return ...
Thanks
-- | Invokes collect for each data collector.
collection :: CollectorMap -> IO CollectorMap
--
2.2.0.rc0.207.ga3a616c