On Thu, Mar 15, 2018 at 3:20 PM, Rainer Jung <[email protected]> wrote:
>
> For the sake of completeness, here are the full trace8 (failed) startup logs
> for this reproduction scenario:
Thanks Rainer!
Could you (or Steffen, or Lucas) try the attached patch? It's based on
2.4.x, but should work for trunk too..
Regards,
Yann.
Index: modules/slotmem/mod_slotmem_shm.c
===================================================================
--- modules/slotmem/mod_slotmem_shm.c (revision 1826753)
+++ modules/slotmem/mod_slotmem_shm.c (working copy)
@@ -274,11 +274,25 @@ static apr_status_t restore_slotmem(sharedslotdesc
return rv;
}
+static APR_INLINE int is_child_process(void)
+{
+#ifdef WIN32
+ return getenv("AP_PARENT_PID") != NULL;
+#else
+ return 0;
+#endif
+}
+
static apr_status_t cleanup_slotmem(void *is_startup)
{
int is_exiting = (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_EXITING);
ap_slotmem_instance_t *mem;
+ if (is_child_process()) {
+ *retained_globallistmem = globallistmem = NULL;
+ return APR_SUCCESS;
+ }
+
/* When in startup/pre-config's cleanup, the retained data and global pool
* are not used yet, but the SHMs contents were untouched hence they don't
* need to be persisted, simply unlink them.
@@ -439,8 +453,13 @@ static apr_status_t slotmem_create(ap_slotmem_inst
{
if (fbased) {
- apr_shm_remove(fname, pool);
- rv = apr_shm_create(&shm, size, fname, gpool);
+ if (is_child_process()) {
+ rv = apr_shm_attach(&shm, fname, gpool);
+ }
+ else {
+ apr_shm_remove(fname, pool);
+ rv = apr_shm_create(&shm, size, fname, gpool);
+ }
}
else {
rv = apr_shm_create(&shm, size, NULL, pool);
@@ -447,9 +466,9 @@ static apr_status_t slotmem_create(ap_slotmem_inst
}
ap_log_error(APLOG_MARK, rv == APR_SUCCESS ? APLOG_DEBUG : APLOG_ERR,
rv, ap_server_conf, APLOGNO(02611)
- "create: apr_shm_create(%s) %s",
- fname ? fname : "",
- rv == APR_SUCCESS ? "succeeded" : "failed");
+ "create: apr_shm_%s(%s) %s",
+ fbased && is_child_process() ? "attach" : "create",
+ fname, rv == APR_SUCCESS ? "succeeded" : "failed");
if (rv != APR_SUCCESS) {
return rv;
}
@@ -811,7 +830,10 @@ static int pre_config(apr_pool_t *pconf, apr_pool_
}
globallistmem = *retained_globallistmem;
- if (ap_state_query(AP_SQ_MAIN_STATE) != AP_SQ_MS_CREATE_PRE_CONFIG) {
+ if (is_child_process()) {
+ gpool = pconf;
+ }
+ else if (ap_state_query(AP_SQ_MAIN_STATE) != AP_SQ_MS_CREATE_PRE_CONFIG) {
gpool = ap_pglobal;
}
else {