From: Peter Vereshagin <peter@vereshagin.org>
To: Jakub Narebski <jnareb@gmail.com>
Cc: Petr Baudis <pasky@suse.cz>, Eric Wong <normalperson@yhbt.net>,
git@vger.kernel.org, Sam Vilain <sam.vilain@catalyst.net.nz>,
Juan Jose Comellas <juanjo@comellas.org>,
John Goerzen <jgoerzen@complete.org>
Subject: Re: [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script
Date: Sat, 15 May 2010 14:06:15 +0400 [thread overview]
Message-ID: <20100515100615.GA3564@screwed.box> (raw)
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
next prev parent reply other threads:[~2010-05-15 10:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-07 12:54 [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script Jakub Narebski
2010-05-07 12:54 ` [PATCH/RFC 1/2] gitweb: Put all per-connection code in run() subroutine Jakub Narebski
2010-05-07 12:54 ` [RFC/PATCH 2/2] gitweb: Add support for FastCGI, using CGI::Fast Jakub Narebski
2010-05-08 7:59 ` [RFC/PATCHv2 " Jakub Narebski
2010-05-08 22:41 ` [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script Jakub Narebski
2010-05-09 9:31 ` Eric Wong
2010-05-09 11:48 ` Ævar Arnfjörð Bjarmason
2010-05-09 12:39 ` Jakub Narebski
2010-05-09 16:47 ` Peter Vereshagin
2010-05-09 18:18 ` Jakub Narebski
2010-05-10 7:13 ` Peter Vereshagin
2010-05-10 15:29 ` Jakub Narebski
2010-05-11 6:24 ` Peter Vereshagin
2010-05-11 8:35 ` Petr Baudis
2010-05-11 10:58 ` Jakub Narebski
2010-05-11 12:09 ` Peter Vereshagin
2010-05-11 13:51 ` Jakub Narebski
2010-05-13 13:10 ` Peter Vereshagin
2010-05-13 17:13 ` Ævar Arnfjörð Bjarmason
2010-05-14 15:58 ` Peter Vereshagin
2010-05-14 10:53 ` Jakub Narebski
2010-05-14 15:36 ` Peter Vereshagin
2010-05-14 17:58 ` Jakub Narebski
2010-05-14 18:43 ` Jakub Narebski
2010-05-15 10:06 ` Peter Vereshagin [this message]
2010-05-15 13:58 ` Jakub Narebski
2010-05-16 10:15 ` Peter Vereshagin
2010-05-18 1:06 ` Jakub Narebski
2010-05-16 10:26 ` Petr Baudis
2010-05-15 11:51 ` Petr Baudis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100515100615.GA3564@screwed.box \
--to=peter@vereshagin.org \
--cc=git@vger.kernel.org \
--cc=jgoerzen@complete.org \
--cc=jnareb@gmail.com \
--cc=juanjo@comellas.org \
--cc=normalperson@yhbt.net \
--cc=pasky@suse.cz \
--cc=sam.vilain@catalyst.net.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.