2

I'm developing an Apache based application witch few custom modules.

I'd like to share some functionality in one module with others. I need to wire them together during stratup phase. I want to use GetModuleHandle + GetProcAddress (it will rununder Windows only) with a module name - but this will succeed only if the module is already loaded by Apache server.

Is there a way to configure the loading order of Apache modules. I only need to control my modules - others are irrelevant.

Thank's in advance.

Łukasz Bownik
  • 6,149
  • 12
  • 42
  • 60
  • 1
    I think (but I'm not sure, so don't take this as authoritative) modules are loaded in the order in which the `LoadModule` directives appear in the configuration file(s). You should probably just fail with an error if `GetModuleHandle` fails and document the fact that order is important. – larsks Apr 24 '12 at 15:09

1 Answers1

1

If you're trying to control the Apache hook calling order from the source of your module, you can try using APR_HOOK_FIRST, APR_HOOK_MIDDLE, and APR_HOOK_LAST. Or you can specifically name other modules to enforce ordering constraints. From the docs:

... "There are two mechanisms for doing this. The first, rather crude, method, allows us to specify roughly where the hook is run relative to other modules. The final argument control this. There are three possible values: APR_HOOK_FIRST, APR_HOOK_MIDDLE and APR_HOOK_LAST.

"All modules using any particular value may be run in any order relative to each other, but, of course, all modules using APR_HOOK_FIRST will be run before APR_HOOK_MIDDLE which are before APR_HOOK_LAST. Modules that don't care when they are run should use APR_HOOK_MIDDLE. These values are spaced out, so that positions like APR_HOOK_FIRST-2 are possible to hook slightly earlier than other functions. ...

"The other method allows finer control. When a module knows that it must be run before (or after) some other modules, it can specify them by name. The second (third) argument is a NULL-terminated array of strings consisting of the names of modules that must be run before (after) the current module. For example, suppose we want "mod_xyz.c" and "mod_abc.c" to run before we do, then we'd hook as follows ..." [example follows]

Community
  • 1
  • 1
cce
  • 4,874
  • 2
  • 28
  • 25