I had the express pleasure of debugging for hours a quirk in the design for Apache 2.4 while building a cross platform module.
The problem I faced is that Apache, when starting, loads the configuration file twice, and thus loads the module itself twice. Once I guess to test the configuration and read the command struct and then the next to fill in the blanks for the server to run. This would not normally be of any issue, but I needed to load my module's configuration at load time before serving any clients and only parse my module's needs ONCE AND ONCE ONLY.
Since I use a number of resources including databases and the like, I decided running multiple times is not the best idea, especially when taking hits on a database server.
The online manual ("Developer API 2.5") says to instead of using an old method, which I will leave the reader to look up, to use ap_retained_data_get and ap_retained_data_create to retain data across module unloading. Preferably to pass a flag to the next phase that you have passed the testing phase already.
Herein is where the headache lies. This is not the way it works on Windows.
Linux does operate in two passes, but Windows works in four passes.
Using this method in the post config read hook works for Linux but not Windows
Please note that I am export C++ code in my modules, hence the use of classes. Also some of the variable declarations are absent for brevity.
So this should be enough for Windows right? Wrong. I had to learn this backwards because I am building on Windows first, but Windows has four passes instead of two. There for your initialization will still run twice.
My next solution was as follows:
Seemed to work.... Ok, I am done with that part, right? WRONG! I got over to the Linux box and segfault city. I am sure that plenty of seasoned Apache developers are probably shaking their heads right now, but these are the same guys who are not documenting these issues.
My final fix was to wrap the Windows code in define blocks. I am not sure if there was a better way or not, but it worked for me. So the following works on both platforms without segfault.
Hopefully, someone else may benefit from this.