diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-26 19:38:27 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-26 19:38:27 -0400 |
commit | 26fb68355b4ad95f99b2d14110e683109d0bab3d (patch) | |
tree | 7c022bafa308328672341824ef5ac38974a80202 /Assistant/Threads/NetWatcher.hs | |
parent | 3c0cc8b6c68b4b09668142b202a068b0ae23998c (diff) |
NetWatcher: When dbus connection is lost, try to reconnect.
MountWatcher can't do this, because it uses the session dbus,
and won't have access to the new DBUS_SESSION_BUS_ADDRESS if a new session
is started.
Bumped dbus library version, FD leak in it is fixed.
Diffstat (limited to 'Assistant/Threads/NetWatcher.hs')
-rw-r--r-- | Assistant/Threads/NetWatcher.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs index f9ca5641d..96b8007cc 100644 --- a/Assistant/Threads/NetWatcher.hs +++ b/Assistant/Threads/NetWatcher.hs @@ -24,7 +24,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 @@ -57,22 +56,24 @@ netWatcherFallbackThread st dstatus scanremotes = thread $ #if WITH_DBUS dbusThread :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> IO () -dbusThread st dstatus scanremotes = E.catch (runClient getSystemAddress go) onerr +dbusThread st dstatus scanremotes = 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 + 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. -} |