]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
The environment may be manipulated by modules such as mod_perl, so regenerate
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 5 Jun 2008 19:01:11 +0000 (19:01 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 5 Jun 2008 19:01:11 +0000 (19:01 +0000)
the passed env argument on each CreateProcess call.

PR: 44800 (part 2/3)
Submitted by: tdonovan
Backports: r663699

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@663701 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/winnt/mpm_winnt.c

index 1a438fb53b39d5314a6d99e2e90d7cc4924ae409..c766f44416f56e25db64e345f81c3b942c60e496 100644 (file)
@@ -617,7 +617,6 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_
     /* These NEVER change for the lifetime of this parent 
      */
     static char **args = NULL;
-    static char **env = NULL;
     static char pidbuf[28];
 
     apr_status_t rv;
@@ -629,6 +628,8 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_
     HANDLE waitlist[2];  /* see waitlist_e */
     char *cmd;
     char *cwd;
+    char **env;
+    int envc;
 
     apr_pool_sub_make(&ptemp, p, NULL);
 
@@ -713,21 +714,15 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_
         return -1;
     }
 
-    if (!env) 
-    {
-        /* Build the env array, only once since it won't change 
-         * for the lifetime of this parent process.
-         */
-        int envc;
-        for (envc = 0; _environ[envc]; ++envc) {
-            ;
-        }
-        env = malloc((envc + 2) * sizeof (char*));
-        memcpy(env, _environ, envc * sizeof (char*));
-        apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%i", parent_pid);
-        env[envc] = pidbuf;
-        env[envc + 1] = NULL;
+    /* Build the env array */
+    for (envc = 0; _environ[envc]; ++envc) {
+        ;
     }
+    env = apr_palloc(ptemp, (envc + 2) * sizeof (char*));  
+    memcpy(env, _environ, envc * sizeof (char*));
+    apr_snprintf(pidbuf, sizeof(pidbuf), "AP_PARENT_PID=%i", parent_pid);
+    env[envc] = pidbuf;
+    env[envc + 1] = NULL;
 
     rv = apr_proc_create(&new_child, cmd, args, env, attr, ptemp);
     if (rv != APR_SUCCESS) {