Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
laziness, impatience, and hubris
 
PerlMonks  

Fastcgi, howto deal with exit?

by horshack (Acolyte)
on Aug 12, 2006 at 09:57 UTC ( [id://567032]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

horshack has asked for the wisdom of the Perl Monks concerning the following question:

I want to convert a cgi-app to fast-cgi, but there are lots of exit-statements deep in the code. This makes fast-cgi start the whole programm from the very beginning. Some kind of MyModule::exit would be possible, but what should MyModule::exit do? This is testcode I wrote to check it:
#!/usr/bin/perl use CGI::Fast qw(:standard); our $COUNTER = 0; while ( my $wwwform = CGI::Fast->new() ) { my $dinner = Dinner->new($wwwform); $dinner->serve( $COUNTER++ ); } # Now the stuff long existing... package Dinner; use CGI::Fast qw(:standard); sub new { my ( $class, $wwwform ) = @_; bless { wwwform => $wwwform }, $class; } sub serve { my ( $self, $counter ) = @_; print header, start_html('Fast CGI Test'); printf "It's %s<br />", scalar localtime; print "Counter is $counter<br />"; print end_html; # BAD! But in several parts of code... # Fastcgi-mainprogramm exits and starts to run on next # request from the very beginning, loading tons of modules # etc. exit; # Dinner::Base::exit() # ???? } 1;

Replies are listed 'Best First'.
Re: Fastcgi, howto deal with exit?
by Fletch (Bishop) on Aug 12, 2006 at 10:06 UTC

    You don't want to exit, you want to return from the serve method so you go through the while loop again to process the next request.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://567032]
Approved by chargrill
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.