summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Threads/DaemonStatus.hs2
-rw-r--r--Assistant/Threads/TransferPoller.hs2
-rw-r--r--Utility/NotificationBroadcaster.hs17
-rw-r--r--debian/changelog2
4 files changed, 17 insertions, 6 deletions
diff --git a/Assistant/Threads/DaemonStatus.hs b/Assistant/Threads/DaemonStatus.hs
index fffc6ed37..5bbb15acb 100644
--- a/Assistant/Threads/DaemonStatus.hs
+++ b/Assistant/Threads/DaemonStatus.hs
@@ -17,7 +17,7 @@ import Utility.NotificationBroadcaster
-}
daemonStatusThread :: NamedThread
daemonStatusThread = namedThread "DaemonStatus" $ do
- notifier <- liftIO . newNotificationHandle
+ notifier <- liftIO . newNotificationHandle False
=<< changeNotifier <$> getDaemonStatus
checkpoint
runEvery (Seconds tenMinutes) <~> do
diff --git a/Assistant/Threads/TransferPoller.hs b/Assistant/Threads/TransferPoller.hs
index 20b832652..68075cac8 100644
--- a/Assistant/Threads/TransferPoller.hs
+++ b/Assistant/Threads/TransferPoller.hs
@@ -21,7 +21,7 @@ import qualified Data.Map as M
transferPollerThread :: NamedThread
transferPollerThread = namedThread "TransferPoller" $ do
g <- liftAnnex gitRepo
- tn <- liftIO . newNotificationHandle =<<
+ tn <- liftIO . newNotificationHandle True =<<
transferNotifier <$> getDaemonStatus
forever $ do
liftIO $ threadDelay 500000 -- 0.5 seconds
diff --git a/Utility/NotificationBroadcaster.hs b/Utility/NotificationBroadcaster.hs
index 413ec2d75..b873df655 100644
--- a/Utility/NotificationBroadcaster.hs
+++ b/Utility/NotificationBroadcaster.hs
@@ -40,14 +40,23 @@ data NotificationHandle = NotificationHandle NotificationBroadcaster Notificatio
newNotificationBroadcaster :: IO NotificationBroadcaster
newNotificationBroadcaster = atomically $ newTMVar []
-{- Allocates a notification handle for a client to use. -}
-newNotificationHandle :: NotificationBroadcaster -> IO NotificationHandle
-newNotificationHandle b = NotificationHandle
+{- Allocates a notification handle for a client to use.
+ -
+ - An immediate notification can be forced the first time waitNotification
+ - is called on the handle. This is useful in cases where a notification
+ - may be sent while the new handle is being constructed. Normally,
+ - such a notification would be missed. Forcing causes extra work,
+ - but ensures such notifications get seen.
+ -}
+newNotificationHandle :: Bool -> NotificationBroadcaster -> IO NotificationHandle
+newNotificationHandle force b = NotificationHandle
<$> pure b
<*> addclient
where
addclient = do
- s <- newEmptySV
+ s <- if force
+ then newSV ()
+ else newEmptySV
atomically $ do
l <- takeTMVar b
putTMVar b $ l ++ [s]
diff --git a/debian/changelog b/debian/changelog
index a37eec421..38c329dcd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ git-annex (4.20130324) UNRELEASED; urgency=low
* Group subcommands into sections in usage. Closes: #703797
* Per-command usage messages.
+ * webapp: Fix a race that sometimes caused alerts or other notifications
+ to be missed if they occurred while a page was loading.
-- Joey Hess <joeyh@debian.org> Mon, 25 Mar 2013 10:21:46 -0400