summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-27 14:56:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-27 14:56:20 -0400
commitb9468c73eba89e706dde800eb43a48d682f09b5a (patch)
tree529c1d87944b4fbf867c512722f0a736b46512b1 /Assistant
parentc96dea4df695fb7516ea801ab7909da4bea29bcc (diff)
webapp: Fix a race that sometimes caused alerts or other notifications to be missed if they occurred while a page was loading.
When a page is loaded, the javascript requests an notification url, and does long polling on the url to be informed of changes. But if a change occured before the notification url was requested, it would not be notified of that change, and so the page display would not update. I fixed this by *always* updating the page display after it gets the notification url. This is extra work, but the overhead is not noticable in the other overhead of loading a page. (A nicer way would be to somehow record the version of a page initially loaded, and then compare it with the current version when getting the notification url, and only force an update if it's changed. But getting the "version" of the different parts of the page that use long polling is difficult.)
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Threads/DaemonStatus.hs2
-rw-r--r--Assistant/Threads/TransferPoller.hs2
2 files changed, 2 insertions, 2 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