summaryrefslogtreecommitdiff
path: root/Hsbot/Core.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-05-29 00:55:14 +0200
committerJulien Dessaux2010-05-29 01:01:31 +0200
commitdaea135424857594622573fa1a900b436d7ee0ae (patch)
tree586338270b862a7c44e597828413e918b2cd24a0 /Hsbot/Core.hs
parentCleaned further the bot updates handling. (diff)
downloadhsbot-daea135424857594622573fa1a900b436d7ee0ae.tar.gz
hsbot-daea135424857594622573fa1a900b436d7ee0ae.tar.bz2
hsbot-daea135424857594622573fa1a900b436d7ee0ae.zip
Implemented the clean killing of plugins' threads.
Diffstat (limited to '')
-rw-r--r--Hsbot/Core.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/Hsbot/Core.hs b/Hsbot/Core.hs
index f98fece..fac9f8e 100644
--- a/Hsbot/Core.hs
+++ b/Hsbot/Core.hs
@@ -31,9 +31,11 @@ hsbot config = do
, botResumeData = mvar }
putStrLn "[Hsbot] Entering main loop... "
(status, botState') <- runLoop botState
+ putStrLn "[Hsbot] Killing active plugins... "
resumeData <- takeMVar mvar
+ evalStateT (mapM_ killPlugin $ M.keys resumeData) botState'
if status == BotReboot
- then resumeHsbot botState' resumeData
+ then resumeHsbot resumeData
else return ()
where
runLoop :: BotState -> IO (BotStatus, BotState)
@@ -43,8 +45,8 @@ hsbot config = do
BotContinue -> runLoop botState'
_ -> return (status, botState')
-resumeHsbot :: BotState -> BotResumeData -> IO ()
-resumeHsbot botState resumeData = do
+resumeHsbot :: BotResumeData -> IO ()
+resumeHsbot resumeData = do
print resumeData
-- | Run the bot main loop