cleanup_for_exec() v/s spawn_proc_prog()

cleanup_for_exec() v/s spawn_proc_prog()

am 01.05.2010 21:35:19 von israel.leiva

Hi,

I was just reading about Apache::SubProcess [1] because I wanted to do
something like [2] . But now with Apache2::SubProcess I'm a little bit
confused with the idea of spawn_proc_prog() . I will really appreciate if
someone could explain me the differences between cleanup_for_exec() and
spawn_proc_prog() .


[1]:
http://perl.apache.org/docs/1.0/guide/performance.html#Forki ng_and_Executing_Subprocesses_from_mod_perl

[2]:
http://perl.apache.org/docs/1.0/guide/performance.html#A_Com plete_Fork_Example

--
Israel Leiva

Re: cleanup_for_exec() v/s spawn_proc_prog()

am 02.05.2010 12:30:56 von Michael Ludwig

Hi Israel,

israel.leiva@alumnos.inf.utfsm.cl schrieb am 01.05.2010 um 15:35:19 (-0400):

> I was just reading about Apache::SubProcess [1] because I wanted to do
> something like [2] . But now with Apache2::SubProcess I'm a little bit
> confused with the idea of spawn_proc_prog() . I will really appreciate
> if someone could explain me the differences between cleanup_for_exec()
> and spawn_proc_prog() .

I haven't used this but it looks like $r->cleanup_for_exec is used, in
the child once forked, to close the socket connecting Apache and the
client, failing which the child will hold on to the socket as long as
it runs, which will prevent Apache from reclaiming the same address on
restart (as explained in "Freeing the Parent Process" on the page you're
referring to).

Looks like cleanup_for_exec was part of a mod_perl 1.0 third-party
module, isn't needed in mod_perl 2.0 any more and is only provided
as a NOOP in Apache2::compat.

http://perl.apache.org/docs/2.0/user/porting/compat.html#C__ __r_E_gt_cleanup_for_exec___

\,,,/
(o o)
------oOOo-(_)-oOOo------
$r->cleanup_for_exec wasn't a part of the mp1 core API, but
lived in a 3rd party module Apache2::SubProcess [this should
read Apache::SubProcess - M.L.]. That module's functionality
is now a part of mod_perl 2.0 API. But Apache 2.0 doesn't
need this function any longer.
-------------------------

This is the 1.0 third-party module defining cleanup_for_exec:

http://cpansearch.perl.org/src/DOUGM/Apache-SubProcess-0.03/ SubProcess.xs

The other function you're wondering about, spawn_proc_prog in mod_perl
2.0 (Apache2::SubProcess), seems to be for running external programs
from mod_perl 2.0. The 1.0 equivalents, I think, are described in the
sections "Starting a Long Running External Program" and "Starting a
Short Running External Program" on the page you're referring to.

> [1]:
> http://perl.apache.org/docs/1.0/guide/performance.html#Forki ng_and_Executing_Subprocesses_from_mod_perl
>
> [2]:
> http://perl.apache.org/docs/1.0/guide/performance.html#A_Com plete_Fork_Example

--
Michael Ludwig

Re: Re: cleanup_for_exec() v/s spawn_proc_prog()

am 04.05.2010 07:04:34 von israel.leiva

> Hi Israel,

Hi Michael,

>
> I haven't used this but it looks like $r->cleanup_for_exec is used, in
> the child once forked, to close the socket connecting Apache and the
> client, failing which the child will hold on to the socket as long as
> it runs, which will prevent Apache from reclaiming the same address on
> restart (as explained in "Freeing the Parent Process" on the page you're
> referring to).
>
> Looks like cleanup_for_exec was part of a mod_perl 1.0 third-party
> module, isn't needed in mod_perl 2.0 any more and is only provided
> as a NOOP in Apache2::compat.
>
> http://perl.apache.org/docs/2.0/user/porting/compat.html#C__ __r_E_gt_cleanup_for_exec___
>
> \,,,/
> (o o)
> ------oOOo-(_)-oOOo------
> $r->cleanup_for_exec wasn't a part of the mp1 core API, but
> lived in a 3rd party module Apache2::SubProcess [this should
> read Apache::SubProcess - M.L.]. That module's functionality
> is now a part of mod_perl 2.0 API. But Apache 2.0 doesn't
> need this function any longer.
> -------------------------
> This is the 1.0 third-party module defining cleanup_for_exec:
>
> http://cpansearch.perl.org/src/DOUGM/Apache-SubProcess-0.03/ SubProcess.xs
>
> The other function you're wondering about, spawn_proc_prog in mod_perl
> 2.0 (Apache2::SubProcess), seems to be for running external programs
> from mod_perl 2.0. The 1.0 equivalents, I think, are described in the
> sections "Starting a Long Running External Program" and "Starting a
> Short Running External Program" on the page you're referring to.
>

Thanks for the clarification. Finally I decided to use:

$r->push_handlers( PerlCleanupHandler => sub { $obj->method } );

where $obj->method() executes the (short) external programs after the
request have been served.

--
Israel Leiva