|
|
f0d6ab |
diff --git a/mod_wsgi.c b/mod_wsgi.c
|
|
|
f0d6ab |
index fd304bd..c65344e 100644
|
|
|
f0d6ab |
--- a/mod_wsgi.c
|
|
|
f0d6ab |
+++ b/mod_wsgi.c
|
|
|
f0d6ab |
@@ -13659,14 +13659,37 @@ static int wsgi_hook_init(apr_pool_t *pconf, apr_pool_t *ptemp,
|
|
|
f0d6ab |
* Init function gets called twice during startup, we only
|
|
|
f0d6ab |
* need to actually do anything on the second time it is
|
|
|
f0d6ab |
* called. This avoids unecessarily initialising and then
|
|
|
f0d6ab |
- * destroying Python for no reason.
|
|
|
f0d6ab |
+ * destroying Python for no reason. We also though have to
|
|
|
f0d6ab |
+ * deal with a special case when a graceful restart is done.
|
|
|
f0d6ab |
+ * For that we are only called once, which is generally okay
|
|
|
f0d6ab |
+ * as the 'wsgi_init' key will be set from initial start up
|
|
|
f0d6ab |
+ * of the server. The exception to this is where the module
|
|
|
f0d6ab |
+ * is only loaded into Apache when the server is already
|
|
|
f0d6ab |
+ * running. In this case we have to detect that it is not
|
|
|
f0d6ab |
+ * the initial startup, but a subsequent restart. We can do
|
|
|
f0d6ab |
+ * this by looking at whether the scoreboard has been
|
|
|
f0d6ab |
+ * initialised yet. That is probably enough, but to be safe,
|
|
|
f0d6ab |
+ * also check what generation it is.
|
|
|
f0d6ab |
*/
|
|
|
f0d6ab |
|
|
|
f0d6ab |
apr_pool_userdata_get(&data, userdata_key, s->process->pool);
|
|
|
f0d6ab |
if (!data) {
|
|
|
f0d6ab |
apr_pool_userdata_set((const void *)1, userdata_key,
|
|
|
f0d6ab |
apr_pool_cleanup_null, s->process->pool);
|
|
|
f0d6ab |
- return OK;
|
|
|
f0d6ab |
+
|
|
|
f0d6ab |
+ /*
|
|
|
f0d6ab |
+ * Check for the special case of a graceful restart and
|
|
|
f0d6ab |
+ * the module being loaded for the first time. In this
|
|
|
f0d6ab |
+ * case we still go onto perform initialisation as the
|
|
|
f0d6ab |
+ * initialisation routine for the module will not be
|
|
|
f0d6ab |
+ * called a second time.
|
|
|
f0d6ab |
+ */
|
|
|
f0d6ab |
+
|
|
|
f0d6ab |
+ if (!ap_scoreboard_image ||
|
|
|
f0d6ab |
+ ap_get_scoreboard_global()->running_generation == 0) {
|
|
|
f0d6ab |
+
|
|
|
f0d6ab |
+ return OK;
|
|
|
f0d6ab |
+ }
|
|
|
f0d6ab |
}
|
|
|
f0d6ab |
|
|
|
f0d6ab |
/* Setup module version information. */
|