]> granicus.if.org Git - php/commitdiff
Fix an elusive and intermittent startup SEGV. The problem was
authorAaron Bannert <aaron@php.net>
Sun, 5 May 2002 18:11:41 +0000 (18:11 +0000)
committerAaron Bannert <aaron@php.net>
Sun, 5 May 2002 18:11:41 +0000 (18:11 +0000)
the static string we were using to set an initialization flag
would get remapped to a different location when Apache reloaded
the DSO, causing us to not run our initialization routines.

Submitted by: Justin Erenkrantz <jerenkrantz@apache.org>
Reviewed by: Aaron Bannert (I added the big comment too)

sapi/apache2filter/sapi_apache2.c

index e512a89e8f9aa752e20fb8fb10665f5c997cd202..81f3fd6d0ef879b625e83713f9ede4f63942b7e6 100644 (file)
@@ -454,14 +454,19 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
         * prevents us from starting PHP until the second load. */
        apr_pool_userdata_get(&data, userdata_key, s->process->pool);
        if (data == NULL) {
-               apr_pool_userdata_setn((const void *)1, userdata_key,
-                                                          apr_pool_cleanup_null, s->process->pool);
+               /* We must use set() here and *not* setn(), otherwise the
+                * static string pointed to by userdata_key will be mapped
+                * to a different location when the DSO is reloaded and the
+                * pointers won't match, causing get() to return NULL when
+                * we expected it to return non-NULL. */
+               apr_pool_userdata_set((const void *)1, userdata_key,
+                                                         apr_pool_cleanup_null, s->process->pool);
                return OK;
        }
        else if (data == (const void *)2) {
                return OK;
        }
-       apr_pool_userdata_setn((const void *)2, userdata_key,
+       apr_pool_userdata_set((const void *)2, userdata_key,
                                                   apr_pool_cleanup_null, s->process->pool);
 
        /* Set up our overridden path. */