Skip to content

Commit 4bbf5a0

Browse files
committed
Merge two SEGV fixes from the trunk:
- startup SEGV caused by delaying the initialization too long. - graceful restart SEGV caused by not re-initializing.
1 parent 99a15a9 commit 4bbf5a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sapi/apache2filter/sapi_apache2.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,23 @@ static int
437437
php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
438438
apr_pool_t *ptemp, server_rec *s)
439439
{
440+
void *data = NULL;
441+
const char *userdata_key = "apache2filter_post_config";
442+
443+
/* Apache will load, unload and then reload a DSO module. This
444+
* prevents us from starting PHP until the second load. */
445+
apr_pool_userdata_get(&data, userdata_key, s->process->pool);
446+
if (data == NULL) {
447+
/* We must use set() here and *not* setn(), otherwise the
448+
* static string pointed to by userdata_key will be mapped
449+
* to a different location when the DSO is reloaded and the
450+
* pointers won't match, causing get() to return NULL when
451+
* we expected it to return non-NULL. */
452+
apr_pool_userdata_set((const void *)1, userdata_key,
453+
apr_pool_cleanup_null, s->process->pool);
454+
return OK;
455+
}
456+
440457
tsrm_startup(1, 1, 0, NULL);
441458
sapi_startup(&apache2_sapi_module);
442459
apache2_sapi_module.startup(&apache2_sapi_module);

0 commit comments

Comments
 (0)