You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Issac Goldstand <ma...@beamartyr.net> on 2006/09/26 10:01:48 UTC

dynamically loading hooks

Hi all,
  I wanted to follow-up a bit on a thread that was on the main list 
regarding hooking new hooks (I think there it was suexec_id).  I deleted 
the original posts and don't have "proper" access now to make an elegant 
response, but I wanted to share the idea before I forget it and see if 
someone here could shape it a bit better.  It occurred to me that it may 
be possible to allow for dynamic hooking to a very large extent by using 
dlsym (or some equivalent trick) to turn a string into a function 
pointer in C.  If we could pull that off, it shouldn't be so difficult 
to allow additional hooks to be hooked in the post_config stage.  While 
this wouldn't work for everything, we could pre-create maps for the 
common argument data types (request_rec, server_rec, int, void) and that 
should give us enough to let the user dynamically hook hooks in the 
config.  The configuration directive might look like:

PerlAddHook HookName Some::Module::hook ReturnType ArgCount ArgTypes 
[ArgTypes is limited to predefined allowed types which will be converted 
to the corresponding perl structures]

This even gives us a minor speed boost of not requiring all hooks to be 
hooked to further reduce overhead (since I seem to recall that Stas and 
Doug went to a lot of effort to shave off everything that could be shaved).

Again, this is really more of a brainstorm than a matured 
idea/suggestion, but wanted to get it off my chest :-)

  Issac

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org