From 3a3625922069232145ea1619a93fe688bec090f2 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 4 Nov 2009 01:26:45 +0100 Subject: [PATCH] $cache_grpshared: Introduce support --- gitweb/README | 14 +++++++++++++- gitweb/gitweb.perl | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gitweb/README b/gitweb/README index 7a9e983738..ff0f61c725 100644 --- a/gitweb/README +++ b/gitweb/README @@ -241,7 +241,7 @@ turned off. Lifetime of in-gitweb cache for projects list page, in minutes. By default set to 0, which means tha projects list caching is turned off. - * $cache_dir, $projlist_cache_name + * $cache_dir, $cache_grpshared, $projlist_cache_name The cached list version (cache of Perl structure, not of final output) is stored in "$cache_dir/$projlist_cache_name". $cache_dir should be writable only by processes with the same uid as gitweb @@ -258,6 +258,18 @@ turned off. running with the same uid as gitweb; use this ONLY at secure installations!!! + By default, $cache_grpshared is 0 and the cache file is accessible + only by the webserver uid; however, when it is set to 1, it will + be also set group-readable and group-writable. You can use that + to externally trigger cache re-generation before users may have + chance to trigger them (and wait long time). You could use e.g. + this script: + + perl -le 'require("./gitweb.cgi"); END { my @list = git_get_projects_list(); + cached_project_list_info(\@list, 1, 1, 1); }' >/dev/null + + (You need to run it in the directory of gitweb.cgi in order for + gitweb_config.perl to be loaded properly.) Projects list file format ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ac2559b671..a979ce64de 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -171,6 +171,7 @@ our $projlist_cache_lifetime = 0; # in minutes our $cache_dir = (defined $ENV{'TMPDIR'} ? $ENV{'TMPDIR'} : '/tmp').'/gitweb'; our $projlist_cache_name = 'gitweb.index.cache'; +our $cache_grpshared = 0; # information about snapshot formats that gitweb is capable of serving our %known_snapshot_formats = ( @@ -4299,8 +4300,8 @@ sub cached_project_list_info { } @projects = fill_project_list_info($projlist, $check_forks, $show_ctags); if ($cache_lifetime && - (-d $cache_dir || mkdir($cache_dir, 0700)) && - sysopen(my $fd, "$cache_file.lock", O_WRONLY|O_CREAT|O_EXCL, 0600)) { + (-d $cache_dir || mkdir($cache_dir, $cache_grpshared ? 0770 : 0700)) && + sysopen(my $fd, "$cache_file.lock", O_WRONLY|O_CREAT|O_EXCL, $cache_grpshared ? 0660 : 0600)) { store_fd(\@projects, $fd); close $fd; rename "$cache_file.lock", $cache_file; -- 2.11.4.GIT