Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 6955 invoked by uid 500); 12 Jun 2001 19:00:07 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 6943 invoked from network); 12 Jun 2001 19:00:05 -0000 Message-ID: <3B266611.496935CB@us.ibm.com> Date: Tue, 12 Jun 2001 12:57:21 -0600 From: David McCreedy Reply-To: new-httpd@apache.org X-Mailer: Mozilla 4.72 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: new-httpd@apache.org Subject: [PATCH] TPF: updates to six files Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Below are patches to six files for TPF-specific updates: src/include/ap_config.h src/main/http_config.c src/main/http_main.c src/main/http_protocol.c src/os/tpf/os.c src/os/tpf/os.h These updates are mainly to accommodate changes/enhancments to the TPF operating system itself: allow non-blocking file descriptors now that TPF's select( ) works with non-socket fd's update TPF shutdown code in response to new processing in TPF's Internet Daemon take advantage of fork/exec enhancements on TPF with new code in os.c move TPF-specific printf's for Apache's -V option from http_main.c to os.c Please let me know if you have any questions or concerns. Thank you, David McCreedy McCreedy@us.ibm.com diff -ru3 apache_1.3.20/src/include/ap_config.h apache-patches/src/include/ap_config.h --- apache_1.3.20/src/include/ap_config.h Thu Apr 5 23:13:11 2001 +++ apache-patches/src/include/ap_config.h Tue Jun 5 14:08:11 2001 @@ -914,6 +914,7 @@ #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 -ru3 apache_1.3.20/src/main/http_config.c apache-patches/src/main/http_config.c --- apache_1.3.20/src/main/http_config.c Tue Jan 23 21:11:09 2001 +++ apache-patches/src/main/http_config.c Tue Jun 5 14:08:11 2001 @@ -1745,7 +1745,7 @@ 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 -ru3 apache_1.3.20/src/main/http_main.c apache-patches/src/main/http_main.c --- apache_1.3.20/src/main/http_main.c Thu Apr 12 13:49:26 2001 +++ apache-patches/src/main/http_main.c Tue Jun 5 14:08:11 2001 @@ -3183,7 +3183,7 @@ { int result = 0; -#if !defined(WIN32) && !defined(NETWARE) +#if !defined(WIN32) && !defined(NETWARE) && !defined(TPF) struct stat wrapper; if ((stat(SUEXEC_BIN, &wrapper)) != 0) { @@ -3648,6 +3648,9 @@ 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 @@ -3666,12 +3669,6 @@ #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 @@ -3737,7 +3734,7 @@ #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) @@ -4763,9 +4760,15 @@ 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 -ru3 apache_1.3.20/src/main/http_protocol.c apache-patches/src/main/http_protocol.c --- apache_1.3.20/src/main/http_protocol.c Fri Mar 9 05:10:26 2001 +++ apache-patches/src/main/http_protocol.c Tue Jun 5 14:08:11 2001 @@ -2269,13 +2269,16 @@ 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 @@ * 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 -ru3 apache_1.3.20/src/os/tpf/os.c apache-patches/src/os/tpf/os.c --- apache_1.3.20/src/os/tpf/os.c Fri Mar 9 05:10:51 2001 +++ apache-patches/src/os/tpf/os.c Tue Jun 5 14:08:35 2001 @@ -103,6 +103,7 @@ 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 @@ 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 @@ 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; + +#include + +#endif /* TPF_FORK_EXTENDED */ if (func) { if (result=func(data, NULL)) { @@ -233,12 +241,22 @@ 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 @@ 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 @@ 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 @@ unsetenv (elts[i].key); } } +#endif /* TPF_FORK_EXTENDED */ if (pipe_out) { close(out_fds[1]); @@ -354,7 +385,11 @@ 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, @@ -713,4 +748,38 @@ } 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 -ru3 apache_1.3.20/src/os/tpf/os.h apache-patches/src/os/tpf/os.h --- apache_1.3.20/src/os/tpf/os.h Fri May 11 22:37:23 2001 +++ apache-patches/src/os/tpf/os.h Tue Jun 5 14:08:11 2001 @@ -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 @@ 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;