You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2008/06/05 21:01:11 UTC

svn commit: r663701 - /httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c

Author: wrowe
Date: Thu Jun  5 12:01:11 2008
New Revision: 663701

URL: http://svn.apache.org/viewvc?rev=663701&view=rev
Log:
The environment may be manipulated by modules such as mod_perl, so regenerate
the passed env argument on each CreateProcess call.

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

Modified:
    httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c

Modified: httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c?rev=663701&r1=663700&r2=663701&view=diff
==============================================================================
--- httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c (original)
+++ httpd/httpd/branches/2.0.x/server/mpm/winnt/mpm_winnt.c Thu Jun  5 12:01:11 2008
@@ -617,7 +617,6 @@
     /* 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 @@
     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 @@
         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) {