Changes with Apache 1.3.21
+ *) (TPF only) Take advantage of improvements to select(), fork(), and
+ exec() in the TPF operating system.
+ [David McCreedy <McCreedy@us.ibm.com>]
+
*) (Cygwin only) Fix problems with signals sent to child processes;
Improve auto-configuration for Cygwin.
[Stipe Tolj <tolj@wapme-systems.de>]
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
+#include <unistd.h>
#define crypt(buf,salt) ((char *)buf)
#undef offsetof
#define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field))
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
{
int result = 0;
-#if !defined(WIN32) && !defined(NETWARE)
+#if !defined(WIN32) && !defined(NETWARE) && !defined(TPF)
struct stat wrapper;
if ((stat(SUEXEC_BIN, &wrapper)) != 0) {
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
#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
#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)
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 */
}
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);
* 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
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
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;
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)) {
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;
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]);
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)
unsetenv (elts[i].key);
}
}
+#endif /* TPF_FORK_EXTENDED */
if (pipe_out) {
close(out_fds[1]);
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,
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
+
+}
#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)
#include <errno.h>
#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 <stdlib.h>
+#if defined(environ) && !defined(TPF_FORK_EXTENDED)
+#define TPF_FORK_EXTENDED
+#endif
+#include <sysapi.h>
#include "ap_config.h"
#ifdef HAVE_ISNAN
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;