Re: MaxRequestsPerChild; which request am I?

2003-04-04 Thread Brian Reichert
On Thu, Apr 03, 2003 at 11:10:58PM -0800, Bill Moseley wrote:
 On Fri, 4 Apr 2003, Brian Reichert wrote:
 
  Dunno if someone has a good answer, or a suggestion of a better
  forum for this:
  
  Apache has a configuration directive: MaxRequestsPerChild
  
http://httpd.apache.org/docs/mod/core.html#maxrequestsperchild
  
  In messing with Apache 1.x, is there a way, via mod-perl, of a
  request knowing how many requests have been served by the current
  child?
 
 
 $request++;
 
 That's what I do in some handler, and then I log it along with the PID.

Eh?  I'm confused.  What is '$request' in that example?  If you
mean it's the request object, then that doesn't do what I expect.

This code:

  warn request is [.$r.]\n;

yields:

  request is [Apache::Request=SCALAR(0x862a9ec)]

 -- 
 Bill Moseley [EMAIL PROTECTED]

-- 
Brian 'you Bastard' Reichert[EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA BSD admin/developer at large


Re: MaxRequestsPerChild; which request am I?

2003-04-04 Thread Bill Moseley
On Fri, 4 Apr 2003, Brian Reichert wrote:

   In messing with Apache 1.x, is there a way, via mod-perl, of a
   request knowing how many requests have been served by the current
   child?
  
  
  $request++;
  
  That's what I do in some handler, and then I log it along with the PID.
 
 Eh?  I'm confused.  What is '$request' in that example?  If you
 mean it's the request object, then that doesn't do what I expect.

No, it's a simple counter.  It's just a variable in some module that
counts requests.






-- 
Bill Moseley [EMAIL PROTECTED]



Re: MaxRequestsPerChild; which request am I?

2003-04-04 Thread Matt



 $request++;

 That's what I do in some handler, and then I log it along with the PID.
Eh?  I'm confused.  What is '$request' in that example?  If you
mean it's the request object, then that doesn't do what I expect.
This code:

  warn request is [.$r.]\n;

yields:

  request is [Apache::Request=SCALAR(0x862a9ec)]
I am pretty sure what he is proposing as a solution (something which I have 
also done):

Set a normal var to 0 (say in a PerlChildInitHandler)
Then in the PerlHandler increment the normal var
$phase = $r-current_callback;

if ($phase eq 'PerlChildInitHandler')
{
   $reqCtr = 0;
}
if ($phase eq 'PerlHandler')
{
   $reqCtr++;
}
Or, you could use a note and skip the global scalar.

I don't think mod_perl has direct access to the current count (at least not 
in mp1).

Matt









Re: MaxRequestsPerChild; which request am I?

2003-04-04 Thread Brian Reichert
On Fri, Apr 04, 2003 at 08:38:53AM -0800, Bill Moseley wrote:
 On Fri, 4 Apr 2003, Brian Reichert wrote:
  Eh?  I'm confused.  What is '$request' in that example?  If you
  mean it's the request object, then that doesn't do what I expect.
 
 No, it's a simple counter.  It's just a variable in some module that
 counts requests.

Ah!  you're maintaining your own counter; I see.

I was looking for this element of Apache's own bookkeeping to be
exposed; I suppose I should have been more specific.

So, not that Bill's solution is unusable to me, let me ask my
question a bit more specifically:

Deep in the guts of http_main.c of Apache's source, I see code like
this:

  void worker_main(void)
  {
  ...

  int total_jobs = 0;

  ...

   if (max_jobs_per_exe  (total_jobs  max_jobs_per_exe)) {
/* Reached MaxRequestsPerChild. Stop accepting new connections
 * and signal the parent to start a new child process.
 */
ap_start_restart(1);
break;
}

Is this 'total_jobs' exposed somehow via an Apache object?  Or do
I need to maintain my own counter, as per Bill's solution?
  
 -- 
 Bill Moseley [EMAIL PROTECTED]

-- 
Brian 'you Bastard' Reichert[EMAIL PROTECTED]
37 Crystal Ave. #303Daytime number: (603) 434-6842
Derry NH 03038-1713 USA BSD admin/developer at large


Re: MaxRequestsPerChild; which request am I?

2003-04-04 Thread Perrin Harkins
Brian Reichert wrote:
Is this 'total_jobs' exposed somehow via an Apache object?
The documentation for the Apache module doesn't say anything about it, 
so I think you have your answer.  We just use a global for this in 
Apache::SizeLimit.

- Perrin



Re: MaxRequestsPerChild; which request am I?

2003-04-03 Thread Bill Moseley
On Fri, 4 Apr 2003, Brian Reichert wrote:

 Dunno if someone has a good answer, or a suggestion of a better
 forum for this:
 
 Apache has a configuration directive: MaxRequestsPerChild
 
   http://httpd.apache.org/docs/mod/core.html#maxrequestsperchild
 
 In messing with Apache 1.x, is there a way, via mod-perl, of a
 request knowing how many requests have been served by the current
 child?


$request++;

That's what I do in some handler, and then I log it along with the PID.




-- 
Bill Moseley [EMAIL PROTECTED]