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

Re: [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script

From
Peter Vereshagin <peter@vereshagin.org>
Date
May 15, 2010, 10:06 UTC
Message-ID
<20100515100615.GA3564@screwed.box>
In-Reply-To
<201005141958.16469.jnareb@gmail.com>

You're face to face with man who sold the world, Jakub! 2010/05/14 19:58:15 +0200 Jakub Narebski <jnareb@gmail.com> => To Peter Vereshagin : JN> You don't see the parsing failure because "do <file>;" functions like JN> "eval", which traps exceptions. You will see consequences of parsing JN> failure (like not defined subroutine). JN> JN> > But you may see it with "use warnings;" right? JN> JN> "use warnings;" pragma doesn't help, because of the 'trapping JN> exceptions' part. That is why "require <file>" is recommended over JN> "do <file>". JN> Checking $@ after "do <file>" would cover the situation where there were JN> parsing errors, but wouldn't cover situation where file was not found, JN> or there was error in executing code (but parsing was O.K.).

I just use it like many others, here are the examples of the code
http://www.jmarshall.com/tools/cgiproxy/ nph-proxy.cgi:
===
    if ($scheme eq 'https') {
  eval { require Net::SSLeay } ;  # don't check during compilation
  &no_SSL_warning($URL) if $@ ;
===
http://webgui.org lib/WebGUI/HTML.pm:
===
  } elsif ($type eq "thumb-if-form-thumb") {
      eval "use Image::Magick;";
      if ($@){
        WebGUI::ErrorHandler::warn("Image::Magick not loaded: ".$@);
===

are those lemmings wrong? By far, people don't use to want the application should be trapped as inclusion fails and they are just sure to deal with the consequences. This is where the php is successful to offer include/include_once as well as its require* counterparters to offer such a choice to a developer. Are those consequences any danger anyway for applications like a gitweb?

Whatever, I almost forgot to ask you again about your mysterious 'The subroutine was defined, but there was a bug in parsing included file'. Does Perl parser has a bug ( about 'bug in parsing' )? file was not included but the sub from it was successfully defined? file was about to include inside a sub but Perl reported the 'sub undefined' instead of 'file has failed to be included by the sub'? All of those seem just incredible to me ;-)

JN> >> Second, "use Module <LIST>;" is equivalent to JN> >> BEGIN { require Module; import Module <LIST>; } JN> >> and therefore it doesn't make sense to use it for conditional inclusion. JN> > JN> > eval() is used there. JN> JN> It's the fact that "use Module" uses BEGIN block that is incompatibile JN> with *conditional* using it from eval.

it works conditionally on those excerpts above. At the moment of the compilation, Perl doesn't know in general case what code should be eval()'d as its argument may vary at the runtime. Therefore Perl do not parse eval() string argument even if it is a constant. And thus it doesn't appear at the BEGIN{} execution moment. This is e.g., how the FCGI::Spawn works with CGI::Fast that defines the socket in its BEGIN{}. You may define your socket communications preference, the FCGI_SOCKET_PATH, on a shell before to start perl, or in the perl, before to eval "use CGI::Fast;" or eval "use FCGI::Spawn"; Both work just fine.

JN> This convertion is JN> a.) compiling CGI file into subroutine (taking care of things like DATA JN> filehandle) using CGI::Compile JN> b.) converting between CGI interface and PSGI interface, using JN> CGI::Emulate::PSGI

Sounds to me like all of that can happen in-memory. Great!

JN> Yes, it can. Depending on request it would run appropriate JN> CGI-converted-to-PSGI application. JN> I am not sure how Plack::App::CGIBin works internally; it migh cimpile JN> all CGI applications upfront; but it might not.

Will challenge.
73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)
-- 
http://vereshagin.org
Previous: Jakub NarebskiNext: Jakub Narebski
Message 25 of 30 in “gitweb: Add support for running gitweb as FastCGI script”
  1. 0/2 gitweb: Add support for running gitweb as FastCGI scriptJakub Narebski, May 7, 2010
  2. 1/2 gitweb: Put all per-connection code in run() subroutineJakub Narebski, May 7, 2010
  3. 2/2 gitweb: Add support for FastCGI, using CGI::FastJakub Narebski, May 7, 2010
  4. 2/2 gitweb: Add support for FastCGI, using CGI::FastJakub Narebski, May 8, 2010
  5. Jakub NarebskiMay 8, 2010
  6. Eric WongMay 9, 2010
  7. Ævar Arnfjörð BjarmasonMay 9, 2010
  8. Jakub NarebskiMay 9, 2010
  9. Peter VereshaginMay 9, 2010
  10. Jakub NarebskiMay 9, 2010
  11. Peter VereshaginMay 10, 2010
  12. Jakub NarebskiMay 10, 2010
  13. Peter VereshaginMay 11, 2010
  14. Petr BaudisMay 11, 2010
  15. Jakub NarebskiMay 11, 2010
  16. Peter VereshaginMay 11, 2010
  17. Jakub NarebskiMay 11, 2010
  18. Peter VereshaginMay 13, 2010
  19. Ævar Arnfjörð BjarmasonMay 13, 2010
  20. Peter VereshaginMay 14, 2010
  21. Jakub NarebskiMay 14, 2010
  22. Peter VereshaginMay 14, 2010
  23. Jakub NarebskiMay 14, 2010
  24. Jakub NarebskiMay 14, 2010
  25. Peter VereshaginMay 15, 2010
  26. Jakub NarebskiMay 15, 2010
  27. Peter VereshaginMay 16, 2010
  28. Jakub NarebskiMay 18, 2010
  29. Petr BaudisMay 16, 2010
  30. Petr BaudisMay 15, 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.