ShutdownException for server shutdown
authorunc0rr
Thu, 24 Feb 2011 22:01:36 +0300
changeset 4959 09f4978b4fb0
parent 4957 3684faf5b3d1
child 4960 3b54b1c9b768
ShutdownException for server shutdown
gameServer/Actions.hs
gameServer/CoreTypes.hs
--- a/gameServer/Actions.hs	Wed Feb 23 18:38:11 2011 +0300
+++ b/gameServer/Actions.hs	Thu Feb 24 22:01:36 2011 +0300
@@ -14,6 +14,7 @@
 import Control.DeepSeq
 import Data.Unique
 import Control.Arrow
+import Control.Exception
 -----------------------------
 import CoreTypes
 import Utils
@@ -415,6 +416,6 @@
 
 processAction (RestartServer force) = do
     if force then do
-        return ()
+        io $ throwIO ShutdownException
         else
         processAction $ ModifyServerInfo (\s -> s{restartPending=True})
--- a/gameServer/CoreTypes.hs	Wed Feb 23 18:38:11 2011 +0300
+++ b/gameServer/CoreTypes.hs	Thu Feb 24 22:01:36 2011 +0300
@@ -1,8 +1,7 @@
-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
 module CoreTypes where
 
 import Control.Concurrent
-import Control.Concurrent.STM
 import Data.Word
 import qualified Data.Map as Map
 import Data.Sequence(Seq, empty)
@@ -11,7 +10,9 @@
 import Data.Function
 import Data.ByteString.Char8 as B
 import Data.Unique
-
+import Control.Exception
+import Data.Typeable
+-----------------------
 import RoomsAndClients
 
 type ClientChan = Chan [B.ByteString]
@@ -190,4 +191,9 @@
 data Notice =
     NickAlreadyInUse
     | AdminLeft
-    deriving Enum
\ No newline at end of file
+    deriving Enum
+
+data ShutdownException = ShutdownException
+     deriving (Show, Typeable)
+
+instance Exception ShutdownException