You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by sr...@symonds.net on 2002/10/15 13:01:33 UTC

ap_rwrite()/ap_rvputs() called in PerlCleanupHandler

Hello,

 I have a mod_perl application which does a internal_redirect() and registers a 
cleanup handler before returning. I am noticing that the cleanup handler 
executes and i see the following in my log ..

[Tue Oct 15 03:27:32 2002] [info] [client XYZ ] (9)Bad file number: client 
stopped connection before rvputs completed

* Why is apache trying to write to client during the cleanup phase ?

Further ...

Since the call is to ap_rvputs(), I assumed it is not a mod_perl issue. I 
confirmed that the handler was 'default-handler' by asking ap_invoke_handler() 
to log each invocation.

But when I forced the handler to be 'perl-script' by using 
internal_redirect_handler(). This time I get 

[Tue Oct 15 00:59:29 2002] [info] [client XYZ] (9)Bad file number: client 
stopped connection before rwrite completed

I hacked ap_rvputs() & ap_rwrite() to not return on a write() failure but to log 
the attempt. It seems that both want to write HTTP headers to client. ( I 
confirmed that it is for the same request 'r->the_request')

Why is apache re-doing the request after a internal_redirect() ? ( and that too 
in the cleanup phase ??)

Please help me understand this. Any hints most appreciated :-)

regards
srp

ps :: please reply to me directly as i am not on the list

Re: ap_rwrite()/ap_rvputs() called in PerlCleanupHandler

Posted by "Ruslan U. Zakirov" <cu...@wr.miee.ru>.
Hello again.
May be it helps to solve your problem.
is_initial_req()

There are several instances in which an incoming URI request can
trigger one or more secondary internal requests. An internal request
is triggered when internal_redirect() is called explicitly, and it
also happens behind the scenes when lookup_file() and lookup_uri()
are called.

With the exception of the logging phase, which is run just once for
the primary request, secondary requests are run through each of the
transaction processing phases, and the appropriate handlers are
called each time. There may be times when you don't want a
particular handler running on a subrequest or internal redirect,
either to avoid performance overhead or to avoid infinite recursion.
The is_initial_req() method will return a true value if the current
request is the primary one and false if the request is the result of
a subrequest or an internal redirect.

return DECLINED unless $r->is_initial_req;

ssn> Hello,

ssn> Why is apache re-doing the request after a internal_redirect() ? ( and that too 
ssn> in the cleanup phase ??)

ssn> Please help me understand this. Any hints most appreciated :-)
                          mailto:cubic@wr.miee.ru


Re: ap_rwrite()/ap_rvputs() called in PerlCleanupHandler

Posted by "Ruslan U. Zakirov" <cu...@wr.miee.ru>.
Hello!

internal_redirect()
 The required argument is an absolute URI path on the current server.
 The server will process the URI as if it were a whole new request,
 running the URI translation, MIME type checking, and other phases
 before invoking the appropriate content handler for the new URI.
 The content handler that eventually runs is not necessarily the same
 as the one that invoked internal_redirect().
 This method should only be called within a content handler.
That from "Writing Apache modules with Perl and C".
ssn> Hello,

ssn> Why is apache re-doing the request after a internal_redirect() ? ( and that too 
ssn> in the cleanup phase ??)

ssn> Please help me understand this. Any hints most appreciated :-)
                         mailto:cubic@wr.miee.ru