git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 18/18] gitweb: Add better error handling for gitweb caching

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 10, 2010, 01:56 UTC
Message-ID
<m3mxoez90s.fsf@localhost.localdomain>
In-Reply-To
<1291931844-28454-19-git-send-email-warthog9@eaglescrag.net>
"John 'Warthog9' Hawley" <warthog9@eaglescrag.net> writes:
Show 9 quoted lines
> This basically finishes the plumbing for caching the error pages
> as the are generated.
> 
> If an error is hit, create a <hash>.err file with the error.  This
> will interrupt all currently waiting processes and they will display
> the error, without any additional refreshing.
> 
> On a new request a generation will be attempted, should it succed the
> <hash.err> file is removed (if it exists).
Could you split 17 and 18 patches slightly differently, at least not
using variables which were not declared first?
 
> Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>

Hmmm... I certainly hope that this complication is not really needed. I have trouble following code flow (no comments), so I'd try to do fresh review again tomorrow.

Show 14 quoted lines
> ---
>  gitweb/gitweb.perl  |    8 ++++++++
>  gitweb/lib/cache.pl |   14 ++++++++++++++
>  2 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index d39982a..5a9660a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -41,6 +41,7 @@ our $version = "++GIT_VERSION++";
>  
>  # Output buffer variable
>  our $output = "";
> +our $output_err = "";
It is used by earlier patches, and declared only there.
Show 8 quoted lines
>  
>  our ($my_url, $my_uri, $base_url, $path_info, $home_link);
>  sub evaluate_uri {
> @@ -303,6 +304,9 @@ our $fullhashpath = *STDOUT;
>  our $fullhashbinpath = *STDOUT;
>  our $fullhashbinpathfinal = *STDOUT;
>  
> +our $cacheErrorCache = 0; # false
$capture_error_output, isn't it?
> +our $cacheErrorCount = 0;
$cached_error_count, or something like that, isn't it?
Show 9 quoted lines
> +
>  our $full_url;
>  our $urlhash;
>  
> @@ -3786,6 +3790,7 @@ sub die_error {
>  	# Reset the output so that we are actually going to STDOUT as opposed
>  	# to buffering the output.
>  	reset_output() if ($cache_enable && ! $cacheErrorCache);
> +	$cacheErrorCount++ if( $cacheErrorCache );
Where it is decremented?  A comment, if you please.
Show 10 quoted lines
>  
>  	git_header_html($http_responses{$status}, undef, %opts);
>  	print <<EOF;
> @@ -3801,6 +3806,9 @@ EOF
>  	print "</div>\n";
>  
>  	git_footer_html();
> +
> +	die_error_cache($output) if ( $cacheErrorCache );
> +
That's cache_die_error_output, or something like that, isn't it?

It's hard to review this patch when die_error_cache is defined in separate (previous) patch.

Show 54 quoted lines
>  	goto DONE_GITWEB
>  		unless ($opts{'-error_handler'});
>  }
> diff --git a/gitweb/lib/cache.pl b/gitweb/lib/cache.pl
> index 6cb82c8..2e7ca69 100644
> --- a/gitweb/lib/cache.pl
> +++ b/gitweb/lib/cache.pl
> @@ -240,8 +240,14 @@ sub cacheUpdate {
>  	# Trap all output from the action
>  	change_output();
>  
> +	# Set the error handler so we cache
> +	$cacheErrorCache = 1; # true
> +
>  	$actions{$action}->();
>  
> +	# Reset Error Handler to not cache
> +	$cacheErrorCache = 0; # false
> +
>  	# Reset the outputs as we should be fine now
>  	reset_output();
>  
> @@ -295,6 +301,8 @@ sub cacheUpdate {
>  		close($cacheFileBG);
>  	}
>  
> +	unlink("$fullhashpath.err") if (-e "$fullhashpath.err");
> +
>  	if ( $areForked ){
>  		exit(0);
>  	} else {
> @@ -339,6 +347,9 @@ sub cacheWaitForUpdate {
>  	my $max = 10;
>  	my $lockStat = 0;
>  
> +	# Call cacheDisplayErr - if an error exists it will display and die.  If not it will just return
> +	cacheDisplayErr($action);
> +
>  	if( $backgroundCache ){
>  		if( -e "$fullhashpath" ){
>  			open($cacheFile, '<:utf8', "$fullhashpath");
> @@ -402,6 +413,9 @@ EOF
>  		close($cacheFile);
>  		$x++;
>  		$combinedLockStat = $lockStat;
> +
> +		# Call cacheDisplayErr - if an error exists it will display and die.  If not it will just return
> +		cacheDisplayErr($action);
>  	} while ((! $combinedLockStat) && ($x < $max));
>  	print <<EOF;
>  </body>
> -- 
> 1.7.2.3
> 
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: John 'Warthog9' HawleyNext: Jakub Narebski
Message 55 of 60 in “Gitweb caching v8”
  1. 00/18 Gitweb caching v8John 'Warthog9' Hawley, Dec 9, 2010
  2. 01/18 gitweb: Prepare for splitting gitwebJohn 'Warthog9' Hawley, Dec 9, 2010
  3. Jakub NarebskiDec 9, 2010
  4. 02/18 gitweb: add output buffering and associated functionsJohn 'Warthog9' Hawley, Dec 9, 2010
  5. 03/18 gitweb: File based caching layer (from git.kernel.org)John 'Warthog9' Hawley, Dec 9, 2010
  6. 04/18 gitweb: Minimal testing of gitweb cachingJohn 'Warthog9' Hawley, Dec 9, 2010
  7. 05/18 gitweb: Regression fix concerning binary output of filesJohn 'Warthog9' Hawley, Dec 9, 2010
  8. Jakub NarebskiDec 9, 2010
  9. 06/18 gitweb: Add more explicit means of disabling 'Generating...' pageJohn 'Warthog9' Hawley, Dec 9, 2010
  10. 07/18 gitweb: Revert back to $cache_enable vs. $caching_enabledJohn 'Warthog9' Hawley, Dec 9, 2010
  11. Jakub NarebskiDec 9, 2010
  12. J.H.Dec 10, 2010
  13. Jakub NarebskiDec 10, 2010
  14. 08/18 gitweb: Change is_cacheable() to return true alwaysJohn 'Warthog9' Hawley, Dec 9, 2010
  15. Jakub NarebskiDec 9, 2010
  16. 09/18 gitweb: Revert reset_output() back to original codeJohn 'Warthog9' Hawley, Dec 9, 2010
  17. Jakub NarebskiDec 9, 2010
  18. J.H.Dec 10, 2010
  19. 10/18 gitweb: Adding isBinaryAction() and isFeedAction() to determine the action typeJohn 'Warthog9' Hawley, Dec 9, 2010
  20. Jakub NarebskiDec 10, 2010
  21. J.H.Dec 10, 2010
  22. Jakub NarebskiDec 10, 2010
  23. Jakub NarebskiDec 10, 2010
  24. 11/18 gitweb: add isDumbClient() checkJohn 'Warthog9' Hawley, Dec 9, 2010
  25. Jakub NarebskiDec 10, 2010
  26. J.H.Dec 10, 2010
  27. Junio C HamanoDec 11, 2010
  28. Jakub NarebskiDec 11, 2010
  29. J.H.Dec 11, 2010
  30. Jakub NarebskiDec 11, 2010
  31. 12/18 gitweb: Change file handles (in caching) to lexical variables as opposed to globsJohn 'Warthog9' Hawley, Dec 9, 2010
  32. Jakub NarebskiDec 10, 2010
  33. Junio C HamanoDec 10, 2010
  34. Jakub NarebskiDec 10, 2010
  35. J.H.Dec 10, 2010
  36. 13/18 gitweb: Add commented url & url hash to page footerJohn 'Warthog9' Hawley, Dec 9, 2010
  37. Jakub NarebskiDec 10, 2010
  38. J.H.Dec 10, 2010
  39. 14/18 gitweb: add print_transient_header() function for central header printingJohn 'Warthog9' Hawley, Dec 9, 2010
  40. Jakub NarebskiDec 10, 2010
  41. J.H.Dec 10, 2010
  42. 15/18 gitweb: Add show_warning() to display an immediate warning, with refreshJohn 'Warthog9' Hawley, Dec 9, 2010
  43. Jakub NarebskiDec 10, 2010
  44. J.H.Dec 10, 2010
  45. Jakub NarebskiDec 10, 2010
  46. 16/18 gitweb: When changing output (STDOUT) change STDERR as wellJohn 'Warthog9' Hawley, Dec 9, 2010
  47. Jakub NarebskiDec 10, 2010
  48. J.H.Dec 12, 2010
  49. Jakub NarebskiDec 12, 2010
  50. 17/18 gitweb: Prepare for cached error pages & better error page handlingJohn 'Warthog9' Hawley, Dec 9, 2010
  51. Jakub NarebskiDec 10, 2010
  52. J.H.Dec 10, 2010
  53. Jakub NarebskiDec 10, 2010
  54. 18/18 gitweb: Add better error handling for gitweb cachingJohn 'Warthog9' Hawley, Dec 9, 2010
  55. Jakub NarebskiDec 10, 2010
  56. Jakub NarebskiDec 9, 2010
  57. J.H.Dec 10, 2010
  58. Jakub NarebskiDec 10, 2010
  59. Junio C HamanoDec 10, 2010
  60. J.H.Dec 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.