Comment 35 for bug 1493372

Notes that will be useful for MOS 8.0, we should stick to the puppet reviews above for MOS 7.0

So, digging into root cause of why mod_wsgi segfaults to have a better fix for MOS 8.0 led to the learning of intricacies of how "apachectl graceful" works with the modules.

mod_wsgi uses ap_hook_post_config to register a wsgi_hook_init which is supposed to fire when the module is initially loaded

in wsgi_hook_init, a global data structure wsgi_server_config is loaded with information:

Note that wsgi_hook_init has a hack to smartly side step the case where wsgi_hook_init is called twice (during apache start)

wsgi_hook_child_init is supposed to be called after wsgi_hook_init and uses the information in wsgi_server_config. Problem is that when graceful is triggered, the is unloaded and reloaded BUT wsgi_hook_init is called just once! As documented in the apache wiki [1] this smart hack fails miserably for our case. As the wiki page eloquently says

"In this case, the post_config hook is executed once after restart and will only set the flag. Module initialization will not be performed, and when child_init and other hooks are called, bad things may happen."

Which is exactly why we fail when we try to use the wsgi_server_config datastructure in wsgi_hook_child_init during the graceful scenario.

Note that all pointers above are to the latest git of mod_wsgi, so it's still not been fixed in mod_wsgi. We need to provide a work around to mod_wsgi community that allows the behavior we need which is load everything the first time wsgi_hook_init is called and don't do anything if it is called again.