Re: cvs: php4 /sapi/fastcgi fastcgi.c
| From: | Andi Gutmans | Date: | Wed, 02 May 2001 17:31:53 +0000 |
| Subject: | Re: cvs: php4 /sapi/fastcgi fastcgi.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-5458@lists.php.net to get a copy of this message | ||
Won't it leak memory for each request? Will messing directly with environ work on all platforms?
Andi
At 05:19 PM 5/2/2001 +0000, Ben Mansell wrote:
joosters Wed May 2 10:19:58 2001 EDTModified files:/php4/sapi/fastcgi fastcgi.cLog: Patch from Stephen Landamore: speed up the environment merging by using memcpy instead of putenv. Index: php4/sapi/fastcgi/fastcgi.c diff -u php4/sapi/fastcgi/fastcgi.c:1.3 php4/sapi/fastcgi/fastcgi.c:1.4--- php4/sapi/fastcgi/fastcgi.c:1.3 Tue Mar 27 07:16:34 2001+++ php4/sapi/fastcgi/fastcgi.c Wed May 2 10:19:58 2001 @@ -281,7 +281,7 @@int max_requests = 500; int requests = 0; int status; - int env_size; + int env_size, cgi_env_size;#ifdef FASTCGI_DEBUGfprintf( stderr, "Initialising now!\n" );@@ -384,21 +384,17 @@fprintf( stderr, "Got accept\n" );#endif- /* Allocate for our environment */ - merge_env = malloc( env_size * sizeof( char *)); - if( !merge_env ) { - perror( "Can't malloc environment" ); - exit( 1 ); - } - memcpy( merge_env, orig_env, env_size * sizeof( char *));-- /* Use the new environment */ - environ = merge_env;-- /* Populate our environment with the CGI's */ - for( i = 0; cgi_env[ i ]; i++ ) { - putenv( cgi_env[ i ] ); - } + cgi_env_size = 0; + while( cgi_env[ cgi_env_size ] ) { cgi_env_size++; } + merge_env = malloc( (env_size+cgi_env_size)*sizeof(char*) ); + if( !merge_env ) { + perror( "Can't malloc environment" ); + exit( 1 ); + } + memcpy( merge_env, orig_env, (env_size-1)*sizeof(char *) ); + memcpy( merge_env + env_size - 1, + cgi_env, (cgi_env_size+1)*sizeof(char *) ); + environ = merge_env;init_request_info( TLS_C SLS_CC ); SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net