Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl
Registry return codes handling (was Re: Possible bug with a 206 Partial Response)
 

Index | Next | Previous | View Flat


stas at stason

Feb 4, 2003, 11:14 PM


Views: 562
Permalink
Registry return codes handling (was Re: Possible bug with a 206 Partial Response)

I did some more tweaking to ModPerl::RegistryCooker. I think my previous
implementation would have problems when the script has changed the status and
then failed (the failure would be ignored then). Please verify that this is
still good (the test suite passes, but it's not exhaustive).

# handlers shouldn't set $r->status but return it, so we reset the
# status after running it
my $old_status = $self->[REQ]->status;
my $rc = $self->run;
my $new_status = $self->[REQ]->status($old_status);

return ($old_status != $new_status && $rc == Apache::OK)
? $new_status
: $rc;

The logic here is simpler:

1. store the new status code (just in case the script has changed it)
2. reset the status code to the one before the script execution
3. if the script has attempted to change the status by itself and the
execution status is Apache::OK return that new status. Otherwise return the
execution status (which will be either Apache::OK or Apache::SERVER_ERROR)

So if that's valid, here are the suggested patches to bring all 3
implementations in sync (David, please check that both Registry and PerlRun
work for you):

Index: lib/Apache/Registry.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/Registry.pm,v
retrieving revision 1.34
diff -u -r1.34 Registry.pm
--- lib/Apache/Registry.pm 23 May 2002 04:21:07 -0000 1.34
+++ lib/Apache/Registry.pm 5 Feb 2003 06:14:00 -0000
@@ -169,7 +169,8 @@
# return REDIRECT;
# }
# }
- return $r->status($old_status);
+ my $new_status = $r->status($old_status);
+ return $old_status != $new_status ? $new_status : OK;
} else {
xlog_error($r, "$filename not found or unable to stat");
return NOT_FOUND unless $Debug && $Debug & 2;
Index: lib/Apache/RegistryNG.pm
===================================================================
RCS file: /home/cvs/modperl/lib/Apache/RegistryNG.pm,v
retrieving revision 1.8
diff -u -r1.8 RegistryNG.pm
--- lib/Apache/RegistryNG.pm 24 Mar 2002 22:06:39 -0000 1.8
+++ lib/Apache/RegistryNG.pm 5 Feb 2003 06:14:00 -0000
@@ -56,7 +56,7 @@
my $pr_status = $pr->status;
$r->status($old_status);

- return ($rc != OK) ? $rc : $pr_status;
+ return ($rc == OK && $old_status != $new_status) ? $pr_status : $rc;
}

1;


__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas[at]stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

Subject User Time
Registry return codes handling (was Re: Possible bug with a 206 Partial Response) stas at stason Feb 4, 2003, 11:14 PM
    Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) geoff at modperlcookbook Feb 10, 2003, 7:20 AM
        Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) stas at stason Feb 10, 2003, 5:09 PM
            Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) david_dick at iprimus Feb 10, 2003, 5:32 PM
                Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) stas at stason Feb 10, 2003, 5:47 PM
                Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) geoff at modperlcookbook Feb 11, 2003, 6:30 AM
            Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) geoff at modperlcookbook Feb 11, 2003, 11:51 AM
                Re: Registry return codes handling (was Re: Possible bug with a 206 Partial Response) stas at stason Feb 11, 2003, 4:21 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.