You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Ed Powell <ep...@visi.com> on 2008/01/29 23:12:46 UTC

pchild pool (Apache 1.3)

I am working on a module for Apache 1.3 (upgrading to 2.x is not an  
option at the moment) where I want to, for each Apache child process  
that spawns, open a file, and keep that file open for reading for the  
life of the child process.  The API document describes a pchild pool  
that sounds exactly like what I want:  lives for the length of the  
child, calls the child_init and child_exit handlers where I can stick  
the ap_fopen and ap_fclose functions into...

Problem is, I have no idea how to use this.  I suppose its more of a  
problem of not knowing how to use pools for storing my own information.

I could allocate sizeof(FILE) to the pchild pool, and I'll get a  
pointer back, and store the file descriptor in there.  Great... now  
how do I tell the rest of the module what that pointer is?  Just put  
in a "static FILE *myfile;" line in the code?  Is that going to be  
multi-process safe?  (I get the feeling I'm asking the wrong  
questions...)


Re: pchild pool (Apache 1.3)

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Ed Powell wrote:
> 
> Problem is, I have no idea how to use this.  I suppose its more of a 
> problem of not knowing how to use pools for storing my own information.
> 
> I could allocate sizeof(FILE) to the pchild pool, and I'll get a pointer 
> back, and store the file descriptor in there.  Great... now how do I 
> tell the rest of the module what that pointer is?  Just put in a "static 
> FILE *myfile;" line in the code?  Is that going to be multi-process 
> safe?  (I get the feeling I'm asking the wrong questions...)

You hit on the reason that apache 1.3 is abandoned.  EAPI solved this
with new field members.  Frontpage solved this with new field members.
 From those two modules alone, you have four different possible binary
compatibility types for third party modules.  Ick :)

Remember unix is a 1:1 process to worker model, so you can throw it in
a global.  Or on win32, it's a 1:1 thread to worker model, so if you
have one to a thread, each can be in a TLS global, or if you know you
are ok on thread safety, you can just put one into a process global.

Bill