Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Issue with Running Long Processes thru CGI

by snoopy (Curate)
on Jul 04, 2006 at 02:20 UTC ( [id://559073]=note: print w/replies, xml ) Need Help??


in reply to Issue with Running Long Processes thru CGI

Hi Sarah,

Just to analyse execution:

use CGI qw(:all delete_all escapeHTML); my $redirect_page = "display_page.cgi"; if (my $session = param('session')) { # returning to pick up session # # ...(2) redirect # my $data = $cache->get($session); if ( $data->[0] ){ # # ...(2a) flag set # } else{ # .... } elsif ( (my $slp = param('sleep')) eq 'sleep') { # ....(1) first invocation $cache->set($session, [0, ""]); # no data yet if (my $pid = fork) { # parent does # # ....(1a) fork: parent # print redirect(self_url()); } elsif (defined $pid) { # child does # # ....(1b) fork: child # $cache->set($session, [1, $buf]); exit 0; } else { # .... } } else { # display form # .... } # ....

When processing a cgi request with query parameter sleep eq 'sleep', you get to (2). A child process is forked, then two things happen concurrently:

  • (1b) set the flag.
  • (1a), redirects to (2), which reads the flag.

The flag may, or may not get 'set' prior to get depending on timing (load, task size, scheduling etc..). This might explain why you are sometimes, but not consistantly getting to (2a).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://559073]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found