gitweb: Show appropriate "Generating..." page when regenerating cache
commit9d92b7dd98dfe78b68117f5985cb761633f57272
authorJakub Narebski <jnareb@gmail.com>
Tue, 9 Feb 2010 13:22:15 +0000 (9 14:22 +0100)
committerJakub Narebski <jnareb@gmail.com>
Tue, 9 Feb 2010 13:22:15 +0000 (9 14:22 +0100)
tree6b71d10eb594beea0cdbdefe1d4f2bbc1b408500
parent7de1a01970b6b5931769e9cfc77110e1c296b6a8
gitweb: Show appropriate "Generating..." page when regenerating cache

NOTE: The test for this feature fails, but that is because of error in
test; manual inspaction of output shows that "Generating..." is
printed correctly.  Also testsuite might fail because correct thread
(correct process) do not see done_testing().

When there exist stale/expired (but not too stale) version of
(re)generated page in cache, gitweb returns stale version (and updates
cache in background, assuming 'background_cache' is set to true value).
When there is no stale version suitable to serve the client, currently
we have to wait for the data to be generated in full before showing it.
Add to GitwebCache::SimpleFileCache, via 'generating_info' callback,
the ability to show user some activity indicator / progress bar, to
show that we are working on generating data.

Gitweb itself uses "Generating..." page as activity indicator, which
redirects (via <meta http-equiv="Refresh" ...>) to refreshed version
of the page after the cache is filled (via trick of not closing page
and therefore not closing connection till data is available in cache,
checked by getting shared/readers lock on lockfile for cache entry).
The git_generating_data_html() subroutine, which is used by gitweb
to implement this feature, is highly configurable: you can choose
initial delay, frequency of writing some data so that connection
won't get closed, and maximum time to wait for data in "Generating..."
page (see %generating_options hash).

Currently git_generating_data_html() contains hardcoded "whitelist" of
actions for which such HTML "Generating..." page makes sense.

This implements final feature from the original gitweb output caching
patch by J.H.

Inspired-by-code-by: John 'Warthog9' Hawley <warthog9@kernel.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
gitweb/cache.pm
gitweb/gitweb.perl
t/t9503/test_cache_interface.pl