bjh 99/04/08 04:36:39
Modified: src/include ap_config.h src/main alloc.c util_script.c src/modules/standard mod_cgi.c mod_include.c src CHANGES Log: OS/2: Rework CGI handling to use spawn*() instead of fork/exec, achieving a roughly 5 fold speed up. Forking really sucks performance wise on OS/2 as it isn't supported by the kernal but fudged in the C libraries for unix compatibility. Revision Changes Path 1.253 +1 -0 apache-1.3/src/include/ap_config.h Index: ap_config.h =================================================================== RCS file: /home/cvs/apache-1.3/src/include/ap_config.h,v retrieving revision 1.252 retrieving revision 1.253 diff -u -r1.252 -r1.253 --- ap_config.h 1999/03/16 16:16:07 1.252 +++ ap_config.h 1999/04/08 11:36:32 1.253 @@ -746,6 +746,7 @@ #define NO_KILLPG #define NEED_STRCASECMP #define NEED_STRNCASECMP +#define NEED_PROCESS_H #define NO_SETSID #define NO_TIMES #define CASE_BLIND_FILESYSTEM 1.107 +50 -2 apache-1.3/src/main/alloc.c Index: alloc.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- alloc.c 1999/03/07 14:05:34 1.106 +++ alloc.c 1999/04/08 11:36:33 1.107 @@ -1671,9 +1671,9 @@ API_EXPORT(void) ap_cleanup_for_exec(void) { -#ifndef WIN32 +#if !defined(WIN32) && !defined(OS2) /* - * Don't need to do anything on NT, because I + * Don't need to do anything on NT or OS/2, because I * am actually going to spawn the new process - not * exec it. All handles that are not inheritable, will * be automajically closed. The only problem is with @@ -2140,6 +2140,54 @@ * unblock alarms and return the pid */ + } +#elif defined(OS2) + { + int save_in=-1, save_out=-1, save_err=-1; + + if (pipe_out) { + save_out = dup(STDOUT_FILENO); + dup2(out_fds[1], STDOUT_FILENO); + close(out_fds[1]); + } + + if (pipe_in) { + save_in = dup(STDIN_FILENO); + dup2(in_fds[0], STDIN_FILENO); + close(in_fds[0]); + } + + if (pipe_err) { + save_err = dup(STDERR_FILENO); + dup2(err_fds[1], STDERR_FILENO); + close(err_fds[1]); + } + + pid = func(data, NULL); + + if ( pid ) + ap_note_subprocess(p, pid, kill_how); + + if (pipe_out) { + close(STDOUT_FILENO); + dup2(save_out, STDOUT_FILENO); + close(save_out); + *pipe_out = out_fds[0]; + } + + if (pipe_in) { + close(STDIN_FILENO); + dup2(save_in, STDIN_FILENO); + close(save_in); + *pipe_in = in_fds[1]; + } + + if (pipe_err) { + close(STDERR_FILENO); + dup2(save_err, STDERR_FILENO); + close(save_err); + *pipe_err = err_fds[0]; + } } #else 1.140 +8 -30 apache-1.3/src/main/util_script.c Index: util_script.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/util_script.c,v retrieving revision 1.139 retrieving revision 1.140 diff -u -r1.139 -r1.140 --- util_script.c 1999/03/10 18:09:44 1.139 +++ util_script.c 1999/04/08 11:36:33 1.140 @@ -695,7 +695,7 @@ #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(OS2) /* the fd on r->server->error_log is closed, but we need somewhere to * put the error messages from the log_* functions. So, we use stderr, * since that is better than allowing errors to go unnoticed. Don't do @@ -770,52 +770,30 @@ } if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) { - int emxloop; - char *emxtemp; - - /* For OS/2 place the variables in the current - * environment then it will be inherited. This way - * the program will also get all of OS/2's other SETs. - */ - for (emxloop = 0; ((emxtemp = env[emxloop]) != NULL); emxloop++) { - putenv(emxtemp); - } - /* More additions by Alec Kloss for OS/2 */ if (is_script) { /* here's the stuff to run the interpreter */ - execl(interpreter + 2, interpreter + 2, r->filename, NULL); + pid = spawnle(P_NOWAIT, interpreter + 2, interpreter + 2, r->filename, NULL, env); } else if (strstr(strupr(r->filename), ".CMD") > 0) { /* Special case to allow use of REXX commands as scripts. */ os2pathname(r->filename); - execl(SHELL_PATH, SHELL_PATH, "/C", r->filename, NULL); + pid = spawnle(P_NOWAIT, SHELL_PATH, SHELL_PATH, "/C", r->filename, NULL, env); } else { - execl(r->filename, argv0, NULL); + pid = spawnle(P_NOWAIT, r->filename, argv0, NULL, env); } } else { - int emxloop; - char *emxtemp; - - /* For OS/2 place the variables in the current - * environment so that they will be inherited. This way - * the program will also get all of OS/2's other SETs. - */ - for (emxloop = 0; ((emxtemp = env[emxloop]) != NULL); emxloop++) { - putenv(emxtemp); - } - if (strstr(strupr(r->filename), ".CMD") > 0) { /* Special case to allow use of REXX commands as scripts. */ os2pathname(r->filename); - execv(SHELL_PATH, create_argv_cmd(r->pool, argv0, r->args, - r->filename)); + pid = spawnve(P_NOWAIT, SHELL_PATH, create_argv_cmd(r->pool, argv0, r->args, + r->filename), env); } else { - execv(r->filename, - create_argv(r->pool, NULL, NULL, NULL, argv0, r->args)); + pid = spawnve(P_NOWAIT, r->filename, + create_argv(r->pool, NULL, NULL, NULL, argv0, r->args), env); } } return (pid); 1.90 +1 -1 apache-1.3/src/modules/standard/mod_cgi.c Index: mod_cgi.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_cgi.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- mod_cgi.c 1999/03/08 15:44:04 1.89 +++ mod_cgi.c 1999/04/08 11:36:34 1.90 @@ -328,7 +328,7 @@ ap_cleanup_for_exec(); child_pid = ap_call_exec(r, pinfo, argv0, env, 0); -#ifdef WIN32 +#if defined(WIN32) || defined(OS2) return (child_pid); #else 1.112 +1 -1 apache-1.3/src/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_include.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -r1.111 -r1.112 --- mod_include.c 1999/03/07 13:13:54 1.111 +++ mod_include.c 1999/04/08 11:36:36 1.112 @@ -822,7 +822,7 @@ /* set shellcmd flag to pass arg to SHELL_PATH */ child_pid = ap_call_exec(r, pinfo, s, ap_create_environment(r->pool, env), 1); -#ifdef WIN32 +#if defined(WIN32) || defined(OS2) return (child_pid); #else /* Oh, drat. We're still here. The log file descriptors are closed, 1.1299 +2 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1298 retrieving revision 1.1299 diff -u -r1.1298 -r1.1299 --- CHANGES 1999/04/07 14:31:19 1.1298 +++ CHANGES 1999/04/08 11:36:37 1.1299 @@ -1,4 +1,6 @@ Changes with Apache 1.3.7 + *) OS/2: Rework CGI handling to use spawn*() instead of fork/exec, achieving + a roughly 5 fold speed up. [Brian Havard] *) proxy ftp: instead of using the hardwired string "text/plain" as a fallback type for files served by the ftp proxy, use the