summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/NetWatcher.hs2
-rw-r--r--Assistant/Threads/PushNotifier.hs20
-rw-r--r--Assistant/Threads/Pusher.hs3
3 files changed, 11 insertions, 14 deletions
diff --git a/Assistant/Threads/NetWatcher.hs b/Assistant/Threads/NetWatcher.hs
index 12e764016..9df4f3a4d 100644
--- a/Assistant/Threads/NetWatcher.hs
+++ b/Assistant/Threads/NetWatcher.hs
@@ -62,7 +62,7 @@ dbusThread = do
)
handleconn = do
debug ["detected network connection"]
- notifyRestart <<~ pushNotifier
+ notifyRestart
handleConnection
onerr e _ = do
liftAnnex $
diff --git a/Assistant/Threads/PushNotifier.hs b/Assistant/Threads/PushNotifier.hs
index 17f966881..b36eb6359 100644
--- a/Assistant/Threads/PushNotifier.hs
+++ b/Assistant/Threads/PushNotifier.hs
@@ -28,17 +28,15 @@ pushNotifierThread :: NamedThread
pushNotifierThread = NamedThread "PushNotifier" $ do
iodebug <- asIO debug
iopull <- asIO pull
- pn <- getAssistant pushNotifier
- controllerThread pn <~> xmppClient pn iodebug iopull
+ iowaitpush <- asIO $ const waitPush
+ ioclient <- asIO2 $ xmppClient $ iowaitpush ()
+ forever $ do
+ tid <- liftIO $ forkIO $ ioclient iodebug iopull
+ waitRestart
+ liftIO $ killThread tid
-controllerThread :: PushNotifier -> IO () -> IO ()
-controllerThread pushnotifier xmppclient = forever $ do
- tid <- forkIO xmppclient
- waitRestart pushnotifier
- killThread tid
-
-xmppClient :: PushNotifier -> ([String] -> IO ()) -> ([UUID] -> IO ()) -> Assistant ()
-xmppClient pushnotifier iodebug iopull = do
+xmppClient :: (IO [UUID]) -> ([String] -> IO ()) -> ([UUID] -> IO ()) -> Assistant ()
+xmppClient iowaitpush iodebug iopull = do
v <- liftAnnex getXMPPCreds
case v of
Nothing -> noop
@@ -63,7 +61,7 @@ xmppClient pushnotifier iodebug iopull = do
threadDelaySeconds (Seconds 300)
loop c =<< getCurrentTime
sendnotifications = forever $ do
- us <- liftIO $ waitPush pushnotifier
+ us <- liftIO iowaitpush
putStanza $ gitAnnexPresence $ encodePushNotification us
receivenotifications = forever $ do
s <- getStanza
diff --git a/Assistant/Threads/Pusher.hs b/Assistant/Threads/Pusher.hs
index 95e4e1276..c87df1610 100644
--- a/Assistant/Threads/Pusher.hs
+++ b/Assistant/Threads/Pusher.hs
@@ -27,8 +27,7 @@ pushRetryThread :: NamedThread
pushRetryThread = NamedThread "PushRetrier" $ runEvery (Seconds halfhour) <~> do
-- We already waited half an hour, now wait until there are failed
-- pushes to retry.
- pushmap <- getAssistant failedPushMap
- topush <- liftIO $ getFailedPushesBefore pushmap (fromIntegral halfhour)
+ topush <- getFailedPushesBefore (fromIntegral halfhour)
unless (null topush) $ do
debug ["retrying", show (length topush), "failed pushes"]
void $ alertWhile (pushRetryAlert topush) $ do