Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Fastcgi, howto deal with exit?

by horshack (Acolyte)
on Aug 12, 2006 at 13:57 UTC ( #567032=perlquestion: print w/replies, xml ) Need Help??
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 (Chancellor) on Aug 12, 2006 at 14: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
Node Status?
node history
Node Type: perlquestion [id://567032]
Approved by chargrill
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-10-21 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (269 votes). Check out past polls.

    Notices?