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

[PATCH 3/5] gitweb: Use nonlocal jump instead of 'exit' in die_error

From
Jakub Narebski <jnareb@gmail.com>
Date
Apr 24, 2010, 13:56 UTC
Message-ID
<20100424135334.30511.26522.stgit@localhost.localdomain>
In-Reply-To
<20100424132255.30511.98829.stgit@localhost.localdomain>

Use 'goto DONE' in place of 'exit' to end request processing in die_error() subroutine. While at it, do not end gitweb with 'exit'.

This would make it easier in the future to add support or improve support for persistent environments such as FastCGI and mod_perl. It would also make it easier to make use of die_error() as an error handler (for fatalsToBrowser).

Perl 5 allows non-local jumps; the restriction is that you cannot jump into a scope.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This patch is most independent of introducing caching support to
gitweb, and I think it would be good to have nevertheless.
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6cefb09..ed92dca 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -972,7 +972,8 @@ if ($action !~ m/^(?:opml|project_list|project_index)$/ &&
 	die_error(400, "Project needed");
 }
 $actions{$action}->();
-exit;
+DONE_GITWEB:
+1;
 
 ## ======================================================================
 ## action links
@@ -3432,7 +3433,7 @@ EOF
 	print "</div>\n";
 
 	git_footer_html();
-	exit;
+	goto DONE_GITWEB;
 }
 
 ## ----------------------------------------------------------------------
Previous: Jakub NarebskiNext: Jakub Narebski
Message 5 of 10 in “gitweb: Miscellaneous improvements, in preparation for caching support”
  1. 0/5 gitweb: Miscellaneous improvements, in preparation for caching supportJakub Narebski, Apr 24, 2010
  2. 1/5 Export more test-related variables when running external testsJakub Narebski, Apr 24, 2010
  3. Jakub NarebskiApr 25, 2010
  4. 2/5 gitweb: href(..., -path_info => 0|1)Jakub Narebski, Apr 24, 2010
  5. 3/5 gitweb: Use nonlocal jump instead of 'exit' in die_errorJakub Narebski, Apr 24, 2010
  6. Jakub NarebskiMay 4, 2010
  7. 4/5 gitweb: Add custom error handler using die_errorJakub Narebski, Apr 24, 2010
  8. 5/5 gitweb: Move generating page title to separate subroutineJakub Narebski, Apr 24, 2010
  9. Petr BaudisApr 25, 2010
  10. Jakub NarebskiApr 25, 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.