Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://567032]
Approved by chargrill
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-06-23 11:17 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.