From: Jeff Trawick Date: Fri, 22 Jun 2001 12:43:55 +0000 (+0000) Subject: These patches affect only TPF. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b83b79ec423d2e45f5c44c1718e9127f6454c47;p=thirdparty%2Fapache%2Fhttpd.git These patches affect only TPF. They are driven by changes to the TPF operating system: updates in shutdown processing to accommodate new code in TPF's Internet Daemon updates to allow non-blocking file descriptors on TPF now that our select() supports non-socket file descriptors changes to os.c to take advantage of TPF's newly enhanced version of fork and exec moving TPF-specific printf's for the -V option from http_main.c to os.c Submitted by: David McCreedy Reviewed by: Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@89404 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index ab31f005483..336db8636af 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 1.3.21 + *) (TPF only) Take advantage of improvements to select(), fork(), and + exec() in the TPF operating system. + [David McCreedy ] + *) (Cygwin only) Fix problems with signals sent to child processes; Improve auto-configuration for Cygwin. [Stipe Tolj ] diff --git a/src/include/ap_config.h b/src/include/ap_config.h index 233ff413054..5571addcfde 100644 --- a/src/include/ap_config.h +++ b/src/include/ap_config.h @@ -914,6 +914,7 @@ typedef int rlim_t; #define S_IREAD S_IRUSR #define S_IWRITE S_IWUSR #define S_IEXEC S_IXUSR +#include #define crypt(buf,salt) ((char *)buf) #undef offsetof #define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field)) diff --git a/src/main/http_config.c b/src/main/http_config.c index c8c46be68a3..ba704a82948 100644 --- a/src/main/http_config.c +++ b/src/main/http_config.c @@ -1745,7 +1745,7 @@ void ap_show_modules(void) for (n = 0; ap_loaded_modules[n]; ++n) { printf(" %s\n", ap_loaded_modules[n]->name); } -#if !defined(WIN32) && !defined(NETWARE) +#if !defined(WIN32) && !defined(NETWARE) && !defined(TPF) printf("suexec: %s\n", ap_suexec_enabled ? "enabled; valid wrapper " SUEXEC_BIN diff --git a/src/main/http_main.c b/src/main/http_main.c index 5b6e096957b..a1f830f9618 100644 --- a/src/main/http_main.c +++ b/src/main/http_main.c @@ -3200,7 +3200,7 @@ static int init_suexec(void) { int result = 0; -#if !defined(WIN32) && !defined(NETWARE) +#if !defined(WIN32) && !defined(NETWARE) && !defined(TPF) struct stat wrapper; if ((stat(SUEXEC_BIN, &wrapper)) != 0) { @@ -3665,6 +3665,9 @@ static void show_compile_settings(void) printf("Server's Module Magic Number: %u:%u\n", MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR); printf("Server compiled with....\n"); +#ifdef TPF + show_os_specific_compile_settings(); +#endif #ifdef BIG_SECURITY_HOLE printf(" -D BIG_SECURITY_HOLE\n"); #endif @@ -3683,12 +3686,6 @@ static void show_compile_settings(void) #ifdef USE_SHMGET_SCOREBOARD printf(" -D USE_SHMGET_SCOREBOARD\n"); #endif -#ifdef USE_TPF_SCOREBOARD - printf(" -D USE_TPF_SCOREBOARD\n"); -#endif -#ifdef NO_SAWNC - printf(" -D NO_SAWNC\n"); -#endif #ifdef USE_OS2_SCOREBOARD printf(" -D USE_OS2_SCOREBOARD\n"); #endif @@ -3754,7 +3751,7 @@ static void show_compile_settings(void) #ifdef HTTPD_ROOT printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n"); #endif -#ifdef SUEXEC_BIN +#if defined(SUEXEC_BIN) && !defined(TPF) printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n"); #endif #if defined(SHARED_CORE) && defined(SHARED_CORE_DIR) @@ -4795,9 +4792,15 @@ static void standalone_main(int argc, char **argv) perform_idle_server_maintenance(); #ifdef TPF - shutdown_pending = os_check_server(tpf_server_name); - ap_check_signals(); - sleep(1); + ap_check_signals(); + if (!shutdown_pending) { + if (os_check_server(tpf_server_name)) { + shutdown_pending++; + } else { + sleep(1); + ap_check_signals(); + } + } #endif /*TPF */ } diff --git a/src/main/http_protocol.c b/src/main/http_protocol.c index 425f0ed437c..41f4af42d2b 100644 --- a/src/main/http_protocol.c +++ b/src/main/http_protocol.c @@ -2269,13 +2269,16 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) long total_bytes_sent = 0; register int n, w, o, len, fd; fd_set fds; +#ifdef TPF + struct timeval tv; +#endif if (length == 0) return 0; /* Make fb unbuffered and non-blocking */ ap_bsetflag(fb, B_RD, 0); -#ifndef TPF +#ifndef TPF_NO_NONSOCKET_SELECT ap_bnonblock(fb, B_RD); #endif fd = ap_bfileno(fb, B_RD); @@ -2334,7 +2337,13 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) * we don't care what select says, we might as well loop back * around and try another read */ +#ifdef TPF_HAVE_NONSOCKET_SELECT + tv.tv_sec = 1; + tv.tv_usec = 0; + ap_select(fd + 1, &fds, NULL, NULL, &tv); +#else ap_select(fd + 1, &fds, NULL, NULL, NULL); +#endif #ifdef NDELAY_PIPE_RETURNS_ZERO afterselect = 1; #endif diff --git a/src/os/tpf/os.c b/src/os/tpf/os.c index ec6662dce09..79db90b79c9 100644 --- a/src/os/tpf/os.c +++ b/src/os/tpf/os.c @@ -103,6 +103,7 @@ int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struc ap_check_signals(); if ((no_reads + no_writes + no_excepts == 0) && (tv) && (tv->tv_sec + tv->tv_usec != 0)) { +#ifdef TPF_HAVE_SAWNC /* TPF's select immediately returns if the sum of no_reads, no_writes, and no_excepts is zero. This means that the select calls in http_main.c @@ -110,7 +111,6 @@ int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struc The following code makes TPF's select work a little closer to everyone else's select: */ -#ifndef NO_SAWNC struct ev0bk evnblock; timeout = tv->tv_sec; @@ -202,6 +202,14 @@ int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), TPF_FORK_CHILD *cld = (TPF_FORK_CHILD *) data; array_header *env_arr = ap_table_elts ((array_header *) cld->subprocess_env); table_entry *elts = (table_entry *) env_arr->elts; +#ifdef TPF_FORK_EXTENDED + char *args[2]; + char **envp = NULL; + pool *subpool = NULL; + +#include "util_script.h" + +#endif /* TPF_FORK_EXTENDED */ if (func) { if (result=func(data, NULL)) { @@ -233,12 +241,22 @@ int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), dup2(err_fds[1], STDERR_FILENO); } +/* set up environment variables for the tpf_fork */ if (cld->subprocess_env) { +#ifdef TPF_FORK_EXTENDED + /* with extended tpf_fork( ) we pass the pointer to a list of pointers */ + /* that point to "key=value" strings for each env variable */ + subpool = ap_make_sub_pool(p); + envp = ap_create_environment(subpool, cld->subprocess_env); +#else + /* without extended tpf_fork( ) we setenv( ) each env variable */ + /* so the child inherits them */ for (i = 0; i < env_arr->nelts; ++i) { if (!elts[i].key) continue; setenv (elts[i].key, elts[i].val, 1); } +#endif /* TPF_FORK_EXTENDED */ } fork_input.program = (const char*) cld->filename; @@ -248,8 +266,15 @@ int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), fork_input.ebw_data = NULL; fork_input.parm_data = NULL; - +#ifdef TPF_FORK_EXTENDED + args[0] = cld->filename; + args[1] = NULL; + if ((pid = tpf_fork(&fork_input, + (const char **)args, + (const char **)envp)) < 0) { +#else if ((pid = tpf_fork(&fork_input)) < 0) { +#endif /* TPF_FORK_EXTENDED */ save_errno = errno; if (pipe_out) { close(out_fds[0]); @@ -264,6 +289,11 @@ int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), pid = 0; } +#ifdef TPF_FORK_EXTENDED + if (subpool) { + ap_destroy_pool(subpool); + } +#else if (cld->subprocess_env) { for (i = 0; i < env_arr->nelts; ++i) { if (!elts[i].key) @@ -271,6 +301,7 @@ int ap_tpf_spawn_child(pool *p, int (*func) (void *, child_info *), unsetenv (elts[i].key); } } +#endif /* TPF_FORK_EXTENDED */ if (pipe_out) { close(out_fds[1]); @@ -354,7 +385,11 @@ pid_t os_fork(server_rec *s, int slot) fork_input.istream = TPF_FORK_IS_BALANCE; fork_input.ebw_data_length = sizeof(input_parms); fork_input.parm_data = "-x"; +#ifdef TPF_FORK_EXTENDED + return tpf_fork(&fork_input, NULL, NULL); +#else return tpf_fork(&fork_input); +#endif /* TPF_FORK_EXTENDED */ } void ap_tpf_zinet_checks(int standalone, @@ -714,3 +749,37 @@ int killpg(pid_t pgrp, int sig) return(0); } + +/* + This function augments http_main's show_compile_settings function. + This way definitions that are only shown on TPF won't clutter up + main line code. +*/ +void show_os_specific_compile_settings(void) +{ + +#ifdef USE_TPF_SCOREBOARD + printf(" -D USE_TPF_SCOREBOARD\n"); +#endif + +#ifdef TPF_FORK_EXTENDED + printf(" -D TPF_FORK_EXTENDED\n"); +#endif + +#ifdef TPF_HAVE_NONSOCKET_SELECT + printf(" -D TPF_HAVE_NONSOCKET_SELECT\n"); +#endif + +#ifdef TPF_NO_NONSOCKET_SELECT + printf(" -D TPF_NO_NONSOCKET_SELECT\n"); +#endif + +#ifdef TPF_HAVE_SAWNC + printf(" -D TPF_HAVE_SAWNC\n"); +#endif + +#ifdef TPF_NO_SAWNC + printf(" -D TPF_NO_SAWNC\n"); +#endif + +} diff --git a/src/os/tpf/os.h b/src/os/tpf/os.h index efc4986095f..cf0b087186f 100644 --- a/src/os/tpf/os.h +++ b/src/os/tpf/os.h @@ -1,8 +1,58 @@ #ifndef APACHE_OS_H #define APACHE_OS_H +/* + * This file is included in all Apache source code. It contains definitions + * of facilities available on _this_ operating system (HAVE_* macros), + * and prototypes of OS specific functions defined in os.c or os-inline.c + */ + #define PLATFORM "TPF" +/************************************************************************ + * PJ26895 provides support for non_socket_select. + * You can determine if this apar is applied to your system by looking + * at i$pwbl.h. If the function non_socket_select is defined, + * then add #define TPF_HAVE_NONSOCKET_SELECT + * else add #define TPF_NO_NONSOCKET_SELECT + * + * One of these two #defines is required and must be added here in os.h + * before the following check. + ************************************************************************/ + +#if !defined(TPF_HAVE_NONSOCKET_SELECT) && !defined(TPF_NO_NONSOCKET_SELECT) + #error "You must define whether your system supports non_socket_select()" + #error "See src/os/tpf/os.h for instructions" +#endif + +#if defined(TPF_HAVE_NONSOCKET_SELECT) && defined(TPF_NO_NONSOCKET_SELECT) + #error "TPF_HAVE_NONSOCKET_SELECT and TPF_NO_NONSOCKET_SELECT" + #error "cannot both be defined" + #error "See src/os/tpf/os.h for instructions" +#endif + +/************************************************************************ + * PJ27387 or PJ26188 provides support for tpf_sawnc. + * You can determine if this apar is applied to your system by looking at + * tpfapi.h or i$fsdd.h. If the function tpf_sawnc is defined, + * then add #define TPF_HAVE_SAWNC + * else add #define TPF_NO_SAWNC + * + * One of these two #defines is required and must be added here in os.h + * before the following check. + ************************************************************************/ + +#if !defined(TPF_HAVE_SAWNC) && !defined(TPF_NO_SAWNC) + #error "You must define whether your system supports tpf_sawnc()" + #error "See src/os/tpf/os.h for instructions" +#endif + +#if defined(TPF_HAVE_SAWNC) && defined(TPF_NO_SAWNC) + #error "TPF_HAVE_SAWNC and TPF_NO_SAWNC" + #error "cannot both be defined" + #error "See src/os/tpf/os.h for instructions" +#endif + /* if the compiler defined errno then undefine it and pick up the correct definition from errno.h */ #if defined(errno) && !defined(__errnoh) @@ -10,12 +60,16 @@ #include #endif -/* - * This file is included in all Apache source code. It contains definitions - * of facilities available on _this_ operating system (HAVE_* macros), - * and prototypes of OS specific functions defined in os.c or os-inline.c - */ +/* If APAR PJ27277 (which shipped on PUT13) has been applied */ +/* then we want to #define TPF_FORK_EXTENDED so Perl CGIs will work. */ +/* Rather than hardcoding it we'll check for "environ" in stdlib.h, */ +/* which was also added by PJ27277. */ +#include +#if defined(environ) && !defined(TPF_FORK_EXTENDED) +#define TPF_FORK_EXTENDED +#endif +#include #include "ap_config.h" #ifdef HAVE_ISNAN @@ -127,6 +181,7 @@ void ap_tpf_zinet_checks(int standalone, const char *servername, struct server_rec *s); int os_check_server(char *server); +void show_os_specific_compile_settings(void); char *getpass(const char *prompt); int killpg(pid_t pgrp, int sig); extern char *ap_server_argv0;