Commit graph

8 commits

Author SHA1 Message Date
Joey Hess
1d0b692198 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.)
2013-03-27 14:56:20 -04:00
Joey Hess
f87a781aa6 finished where indentation changes 2012-12-13 00:24:19 -04:00
Ben Gamari
7fc4ee0dee NotificationBroadcaster: Use SampleVars from SafeSemaphores instead of base
SampleVars from base are unsafe
2012-10-05 17:04:46 -04:00
Joey Hess
6a9abf6526 add NotificationID to StatusR, and use it to block 2012-07-28 21:21:22 -04:00
Joey Hess
5be5cb219f add derives needed for use with Yesod, and fix a bug 2012-07-28 21:11:40 -04:00
Joey Hess
109dc122da add a newtype 2012-07-28 20:30:46 -04:00
Joey Hess
a17fde22fa add a NotificationBroadcaster to DaemonStatus
First use of it is to make the status checkpointer thread block until
there is really a change to the status.
2012-07-28 16:09:34 -04:00
Joey Hess
ca478b7bcb Focus today was writing a notification broadcaster.
This is a way to send a notification to a set of clients, any of which can be
blocked waiting for a new notification to arrive. A complication is that any
number of clients may be be dead, and we don't want stale notifications for
those clients to pile up and leak memory.

It took me 3 tries to find the solution, which turns out to be simple: An array
of SampleVars, one per client. Using SampleVars means that clients only see the
most recent notification, but when the notification is just "the assistant's
state changed somehow; display a refreshed rendering of it", that's sufficient.
2012-07-28 15:41:49 -04:00