summaryrefslogtreecommitdiff
path: root/Assistant/Threads/NetWatcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-26 19:42:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-26 19:42:24 -0400
commit117df9c3714f2366d4f10d63fce41a608d96308e (patch)
tree47155e8948b3137cf2ee527afe2984899a3685eb /Assistant/Threads/NetWatcher.hs
parentd2b9c300b12a025de66f39efafd7962dc591a330 (diff)
parent26fb68355b4ad95f99b2d14110e683109d0bab3d (diff)
Merge branch 'master' into xmpp
Conflicts: Assistant/Threads/NetWatcher.hs
Diffstat (limited to 'Assistant/Threads/NetWatcher.hs')
-rw-r--r--Assistant/Threads/NetWatcher.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs
index 5e6fcea06..883a7bef5 100644
--- a/Assistant/Threads/NetWatcher.hs
+++ b/Assistant/Threads/NetWatcher.hs
@@ -25,7 +25,6 @@ import Utility.DBus
import DBus.Client
import DBus
import Data.Word (Word32)
-import qualified Control.Exception as E
#else
#warning Building without dbus support; will poll for network connection changes
#endif
@@ -59,22 +58,24 @@ netWatcherFallbackThread st dstatus scanremotes pushnotifier = thread $
dbusThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> PushNotifier -> IO ()
dbusThread st dstatus scanremotes pushnotifier =
- E.catch (runClient getSystemAddress go) onerr
+ persistentClient getSystemAddress () onerr go
where
go client = ifM (checkNetMonitor client)
( do
- listenNMConnections client handle
- listenWicdConnections client handle
+ listenNMConnections client handleconn
+ listenWicdConnections client handleconn
, do
runThreadState st $
warning "No known network monitor available through dbus; falling back to polling"
)
- onerr :: E.SomeException -> IO ()
- onerr e = runThreadState st $
- warning $ "dbus failed; falling back to polling (" ++ show e ++ ")"
- handle = do
+ handleconn = do
debug thisThread ["detected network connection"]
handleConnection st dstatus scanremotes pushnotifier
+ onerr e _ = do
+ runThreadState st $
+ warning $ "lost dbus connection; falling back to polling (" ++ show e ++ ")"
+ {- Wait, in hope that dbus will come back -}
+ threadDelaySeconds (Seconds 60)
{- Examine the list of services connected to dbus, to see if there
- are any we can use to monitor network connections. -}