Thanks for the info, its exactly what I needed. -pete
Stas Bekman wrote: > Peter Rothermel wrote: > > Stas Bekman wrote: > > > > > >>Peter Rothermel wrote: > >> > >> > >>>PerlChildInitHandler Apache::foo->loadkey > >>> > >>>Will the genkey method get execute at the > >>>initialization of each thread? > >> > >>Apache doesn't provide such a hook yet. May be in the future. > >> > >>child_init is for child process init, not threads. > >>>http://perl.apache.org/release/docs/2.0/user/handlers/handlers.html#PerlChildInitHandler > >> > >>what are you trying to do? > > > > > > I'm encrypting/decrypting data within cookies that are holding session keys > > for authentication purposes. I decrypt the session key within the cookie data, > > whenever I get an http request that has a cookie in the header. > > > > The RSA keys that I use for encrytion/decryption are regenerated when the Apache > > server is started. My module has a load_key subroutine that I call before I do any > > encryption or decryption. This returns a RSA object that is initialized with a >global > > var that hold a 2048 bit RSA key. If the global var is empty I generate a new key. > > > > The code works OK but I seem to be generating a 2048 bit key the first time > > that a user logs into my site. This key generation takes awhile. I would prefer > > generating the key when server/thread/interupter is started. I was hoping that > > a PerlClhildInitHandler could be used to call the gen_key subroutine to load > > the data into global var $private_key_string. > > There are a few possible approaches to this: > > 1. for mod_perl to provide hooks for the following events: > interp_init (INIT) > interp_destroy (DESTROY) > so these can be run when a new interpreter is initialized after it has > been cloned and when it's going to be destroyed. > > 2. Using the thread interpreter pool mechanism for managing other items. > But it's not clear whether this interface will ever have a Perl API, > because threads::shared already does that. > > 3. Build a pool based on threads::shared. Similar to what Doug has > described in his overview: > >http://perl.apache.org/release/docs/2.0/user/overview/overview.html#Thread_Item_Pool_API > and which is now doable in pure Perl based on threads::shared. This is > an interesting vacant module, but really you can just duplicate the > concepts that Doug has described in the URL above. You want to be able > to add new items, remove them, pop and push from the pool. > > should it be called Threads::TIPool as coined by Doug? (Thread Items Pool) > > Using this (currently not-existing) module you can create a pool of keys > at the server startup and then use them whenever you need a key at run time. > > This is the same concept that the threaded version of Apache::DBI is > going to use, and AFAIK is vacant as well. The challenge is to make it > possible to have modules like Apache::DBI work transparently under > various mpms, including the preforked and perchild mpms. > > __________________________________________________________________ > Stas Bekman JAm_pH ------> Just Another mod_perl Hacker > http://stason.org/ mod_perl Guide ---> http://perl.apache.org > mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com > http://modperlbook.org http://apache.org http://ticketmaster.com