diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-06 14:56:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-06 14:56:04 -0400 |
commit | a00f1d26bc3f121e49ee3f6ff5f46d7b330161ff (patch) | |
tree | 1951e9ca7e482fc67f9c232b0fb22680ee19f5a0 /Assistant/Threads/NetWatcher.hs | |
parent | d11ded822cf68d4f33a886e0f97f95a3781e0dc1 (diff) |
display errors when any named thread crashes
Diffstat (limited to 'Assistant/Threads/NetWatcher.hs')
-rw-r--r-- | Assistant/Threads/NetWatcher.hs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs index 6f6bd40da..b52657990 100644 --- a/Assistant/Threads/NetWatcher.hs +++ b/Assistant/Threads/NetWatcher.hs @@ -15,13 +15,11 @@ import Assistant.ThreadedMonad import Assistant.DaemonStatus import Assistant.ScanRemotes import Assistant.Sync -import qualified Git import Utility.ThreadScheduler import Remote.List import qualified Types.Remote as Remote import qualified Control.Exception as E -import Control.Concurrent #if WITH_DBUS import Utility.DBus @@ -35,18 +33,27 @@ import Data.Word (Word32) thisThread :: ThreadName thisThread = "NetWatcher" -netWatcherThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO () -netWatcherThread st dstatus scanremotes = do +netWatcherThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> NamedThread +netWatcherThread st dstatus scanremotes = thread $ do #if WITH_DBUS - void $ forkIO $ dbusThread st dstatus scanremotes + dbusThread st dstatus scanremotes +#else + noop #endif - {- This is a fallback for when dbus cannot be used to detect - - network connection changes, but it also ensures that - - any networked remotes that may have not been routable for a - - while (despite the local network staying up), are synced with - - periodically. -} + where + thread = NamedThread thisThread + +{- This is a fallback for when dbus cannot be used to detect + - network connection changes, but it also ensures that + - any networked remotes that may have not been routable for a + - while (despite the local network staying up), are synced with + - periodically. -} +netWatcherFallbackThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> NamedThread +netWatcherFallbackThread st dstatus scanremotes = thread $ do runEvery (Seconds 3600) $ handleConnection st dstatus scanremotes + where + thread = NamedThread thisThread #if WITH_DBUS |