httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Ben Hyde)
Subject Adding new module callbacks.
Date Wed, 28 Jan 1998 12:12:55 GMT
This proposal arises out of Dean's recent frustrations
with avoiding the stat calls, and Randy's suggestion
to extend the module structure.  It's a pain that
extending the module structure is so expensive.  What's
in the module structure should only be what a module
must define, not all those things that are optional.

If people like it, maybe somebody can volunteer to
implement it.  This design would need a little sanding
before the varnish is applied.

  /* callback_name(s) are char* text strings.  They are
   * used to name callback entry points defined by the
   * core or modules.  The name is used when creating
   * new named callbacks and when registering a callback
   * with the core. */
  typedef char *callback_name;

  /* Callback_handles provide a handle on each callback
   * routine installed into the core by modules.  They
   * are created via ap_install_callback, and distroyed by
   * ap_deinstall_callback.  Each named callback has one
   * or more recorded for them. */
  typedef ... callback_handle;

  /* ap_install_callback notifies the core that it should
   * invoke the function f in the style implied by 
   * call_back_name in service of requesting_module.  This routine
   * may block momentarily if another thread is updating the
   * callback data structures.  The result denotes how things
   * worked out.
   *    status   implication
   *      0       wonderful
   *      1       deinstalled existing callback
   *     -1       no such callback
  extern int ap_install_callback(
                callback_name name, 
                module *requesting_module, 
                random_function f
                callback_handle *result);

  /* ap_deinstall_callback notifies the core that it should
   * stop calling the function of this callback.  This maybe
   * invoked while a callback is in progress. Once this returns
   * the handle is no longer valid. This routine may block
   * while if another thread is updating the callback data structures. 
   * Return value denotes the status.
   *     0 all done.
   *    -1 unknown handle.
  extern int ap_deinstall_callback(callback_handle handle);

  Enables the core to add new module callbacks without having
to recompile the existing modules.  A good thing as we move
to a DLL model for modules.  Great for unusual workarounds,
like prempting some of the phases.

We could even allow modules to define callbacks for the
use of other modules.

  /* A named_callback_handle provides modules with a handle
   * to the core internal knowledge of a particular named
   * callback.  Modules may create new named_callbacks with
   * ap_create_callback, and may invoke enumerate the functions
   * installed on named callback to implement the acutal
   * callback. 
   typedef ... named_callback_handle;

   /* ap_create_named_callback is used to create a new callback
    * routine in the core.  Other modules may then register
    * with this.  The creating module will invoke the functions
    * registered at the approprate times.  The boolean
    * parameter singular is used to note this more than
    * one module may register with this call back at the
    * same time.
   extern int ap_create_named_callback(
	callback_name name, 
	module *m,
        int singular
	named_callback_handle &result);


This allows the writing of modules that seem to appear to extend core
functionality.  This encourages the illustion that the core is just
a set of modules.


  "module-status-reporter" an ap_callback provided by mod_cool_status

    Modules may install a callback for "module-status-reporter"
    which when mod_cool_status is linked into the server will
    be invoked to request that they add some HTML content to a
    status page indicating the state of their internals.  The
    function installed should have the signature.
        void my_module_status(request_rec *r)

 - ben hyde

View raw message