diff options
Diffstat (limited to 'usr.sbin')
47 files changed, 56 insertions, 5164 deletions
diff --git a/usr.sbin/httpd/src/ap/ap_fnmatch.c b/usr.sbin/httpd/src/ap/ap_fnmatch.c index 4411981cd64..d6f8ed2bc04 100644 --- a/usr.sbin/httpd/src/ap/ap_fnmatch.c +++ b/usr.sbin/httpd/src/ap/ap_fnmatch.c @@ -30,10 +30,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ - /* * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. * Compares a filename or pathname to a pattern. diff --git a/usr.sbin/httpd/src/ap/ap_hook.c b/usr.sbin/httpd/src/ap/ap_hook.c index a5634f0c570..4eb551a1c5a 100644 --- a/usr.sbin/httpd/src/ap/ap_hook.c +++ b/usr.sbin/httpd/src/ap/ap_hook.c @@ -1,6 +1,3 @@ -#if 0 -=pod -#endif /* ==================================================================== * Copyright (c) 1998-2000 The Apache Group. All rights reserved. * @@ -65,11 +62,6 @@ ** See POD document at end of ap_hook.h for description. ** View it with the command ``pod2man ap_hook.h | nroff -man | more'' ** -** Attention: This source file is a little bit tricky. -** It's a combination of a C source and an embedded Perl script -** (which updates the C source). The purpose of this is to have -** both things together at one place. So you can both pass -** this file to the C compiler and the Perl interpreter. */ /* @@ -78,8 +70,6 @@ * -- D. E. Knuth */ -#ifdef EAPI - #include "httpd.h" #include "http_log.h" #include "ap_config.h" @@ -815,116 +805,3 @@ static int ap_hook_call_func(va_list ap, ap_hook_entry *he, ap_hook_func *hf) return rc; } - -#endif /* EAPI */ - -/* -=cut -## -## Embedded Perl script for generating the dispatch section -## - -require 5.003; -use strict; - -# configuration -my $file = $0; -my $begin = '----BEGIN GENERATED SECTION--------'; -my $end = '----END GENERATED SECTION----------'; - -# special command: find used signatures -if ($ARGV[0] eq 'used') { - my @S = `find .. -type f -name "*.c" -print`; - my $s; - my %T = (); - foreach $s (@S) { - $s =~ s|\n$||; - open(FP, "<$s") || die; - my $source = ''; - $source .= $_ while (<FP>); - close(FP); - my %seen = (); - sub printme { - my ($src, $hook, $sig) = @_; - return if ($seen{$hook} == 1); - $seen{$hook} = 1; - my ($rc, $args) = ($sig =~ m|^([^,]+)(.*)$|); - $args =~ s|^,||; - $src =~ s|^.+/||; - my $sig = sprintf("%-6sfunc(%s)", $rc, $args); - $T{$sig}++; - } - $source =~ s|\("([^"]+)",\s*AP_HOOK_SIG[0-9]\((.+?)\)|&printme($s, $1, $2), ''|sge; - } - my $t; - foreach $t (sort(keys(%T))) { - printf(" * %-40s [%dx]\n", $t, $T{$t}); - } - exit(0); -} - -# read ourself and keep a backup -open(FP, "<$file") || die; -my $source = ''; -$source .= $_ while (<FP>); -close(FP); -open(FP, ">$file.bak") || die; -print FP $source; -close(FP); - -# now parse the signature lines and update the code -my $o = ''; -my $next = 0; -my $line; -my %seen = (); -foreach $line (split(/\n/, $source)) { - next if (not $line =~ m|\*\s+\S+\s+func\(.*\)|); - my ($sig, $rc, $param) = ($line =~ m|\*\s+((\S+)\s+func\((.*?)\))|); - $sig =~ s|\s+| |g; - - next if ($seen{$sig} == 1); - $seen{$sig} = 1; - - print "Generating code for `$sig'\n"; - - my @S = ($rc, split(/[\s,]+/, $param)); - my @RS = @S; - my $i; - for ($i = 0; $i <= $#RS; $i++) { - $RS[$i] = 'void *' if ($RS[$i] eq 'ptr'); - $RS[$i] = 'void *' if ($RS[$i] eq 'ctx'); - } - - $o .= "else " if ($next); $next++; - $o .= sprintf("if (he->he_sig == AP_HOOK_SIG%d(%s)) {\n", $#S+1, join(', ',@S)); - $o .= sprintf(" \/\* Call: %s \*\/\n", $sig); - for ($i = 1; $i <= $#S; $i++) { - $o .= sprintf(" %-6sv%d = va_arg(ap, va_type(%s));\n", $RS[$i], $i, $S[$i]); - } - $o .= " "; - $o .= sprintf("*((%s *)v_rc) = ", $RS[0]) if ($S[0] ne 'void'); - $o .= sprintf("((%s(*)(%s))(hf->hf_ptr))", $RS[0], join(', ', @RS[1..$#RS])); - $o .= "("; - for ($i = 1; $i <= $#S; $i++) { - $o .= "hf->hf_ctx" if ($S[$i] eq 'ctx'); - $o .= sprintf("v%d", $i) if ($S[$i] ne 'ctx'); - $o .= ", " if ($i < $#S); - } - $o .= ");\n"; - $o .= sprintf(" rc = (*((%s *)v_rc) != he->he_modeval.v_%s);\n", - $RS[0], $S[0]) if ($S[0] ne 'void'); - $o .= "}\n"; -} - -# insert the generated code at the target location -$o =~ s|^| |mg; -$source =~ s|(\/\* $begin.+?\n).*\n(.*?\/\* $end)|$1$o$2|s; - -# and update the source on disk -print "Updating file `$file'\n"; -open(FP, ">$file") || die; -print FP $source; -close(FP); - -=pod -*/ diff --git a/usr.sbin/httpd/src/ap/ap_signal.c b/usr.sbin/httpd/src/ap/ap_signal.c index 7da2a868676..17293d7667b 100644 --- a/usr.sbin/httpd/src/ap/ap_signal.c +++ b/usr.sbin/httpd/src/ap/ap_signal.c @@ -58,7 +58,6 @@ #include "httpd.h" -#ifndef NO_USE_SIGACTION /* * Replace standard signal() with the more reliable sigaction equivalent * from W. Richard Stevens' "Advanced Programming in the UNIX Environment" @@ -75,7 +74,3 @@ Sigfunc *signal(int signo, Sigfunc * func) return SIG_ERR; return oact.sa_handler; } -#else -/* need some function in this file, otherwise the linker on NeXT bitches */ -void ap_signal_is_not_here(void) {} -#endif diff --git a/usr.sbin/httpd/src/ap/ap_slack.c b/usr.sbin/httpd/src/ap/ap_slack.c index 8a6809d6a9f..b7b3381801e 100644 --- a/usr.sbin/httpd/src/ap/ap_slack.c +++ b/usr.sbin/httpd/src/ap/ap_slack.c @@ -67,24 +67,11 @@ #include "httpd.h" #include "http_log.h" -#ifndef NO_SLACK int ap_slack(int fd, int line) { -#if !defined(F_DUPFD) - return fd; -#else static int low_warned; int new_fd; -#ifdef HIGH_SLACK_LINE - if (line == AP_SLACK_HIGH && fd < HIGH_SLACK_LINE) { - new_fd = fcntl(fd, F_DUPFD, HIGH_SLACK_LINE); - if (new_fd != -1) { - close(fd); - return new_fd; - } - } -#endif /* otherwise just assume line == AP_SLACK_LOW */ if (fd >= LOW_SLACK_LINE) { return fd; @@ -109,9 +96,4 @@ int ap_slack(int fd, int line) } close(fd); return new_fd; -#endif } -#else -/* need at least one function in the file for some linkers */ -void ap_slack_is_not_here(void) {} -#endif /* NO_SLACK */ diff --git a/usr.sbin/httpd/src/ap/ap_strtol.c b/usr.sbin/httpd/src/ap/ap_strtol.c index 26702446302..83d0a2080ad 100644 --- a/usr.sbin/httpd/src/ap/ap_strtol.c +++ b/usr.sbin/httpd/src/ap/ap_strtol.c @@ -178,9 +178,6 @@ API_EXPORT(long) ap_strtol(const char *nptr, char **endptr, int base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) { any = -1; -#ifdef AP_STRTOL_OVERFLOW_IS_BAD_CHAR - break; -#endif } else { any = 1; acc *= base; diff --git a/usr.sbin/httpd/src/include/ap_config.h b/usr.sbin/httpd/src/include/ap_config.h index a7bfede15e6..baa6652df83 100644 --- a/usr.sbin/httpd/src/include/ap_config.h +++ b/usr.sbin/httpd/src/include/ap_config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ap_config.h,v 1.19 2004/12/06 13:14:09 henning Exp $ */ +/* $OpenBSD: ap_config.h,v 1.20 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -77,8 +77,6 @@ extern "C" { */ #include "ap_config_auto.h" -/* Have to include sys/stat.h before ../win32/os.h so we can override -stat() properly */ #include <sys/types.h> #include <sys/stat.h> @@ -87,29 +85,14 @@ stat() properly */ * GNUC attributes (such as to get -Wall warnings for printf-like * functions). Only do this in gcc 2.7 or later ... it may work * on earlier stuff, but why chance it. - * - * We've since discovered that the gcc shipped with NeXT systems - * as "cc" is completely broken. It claims to be __GNUC__ and so - * on, but it doesn't implement half of the things that __GNUC__ - * means. In particular it's missing inline and the __attribute__ - * stuff. So we hack around it. PR#1613. -djg */ -#if !defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\ - defined(NEXT) -#define ap_inline -#define __attribute__(__x) -#define ENUM_BITFIELD(e,n,w) signed int n : w -#else #define ap_inline __inline__ #define USE_GNU_INLINE #define ENUM_BITFIELD(e,n,w) e n : w -#endif #include "os.h" -/* Define one of these according to your system. */ -#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(NETBSD) +/* Define these according to OpenBSD system. */ #define HAVE_GMTOFF 1 #undef NO_KILLPG #undef NO_SETSID @@ -125,16 +108,13 @@ stat() properly */ #define USE_MMAP_SCOREBOARD #define USE_MMAP_FILES #define HAVE_FLOCK_SERIALIZED_ACCEPT -#if defined(__OpenBSD__) #define HAVE_SYSVSEM_SERIALIZED_ACCEPT #define USE_SYSVSEM_SERIALIZED_ACCEPT #include <sys/param.h> #if (OpenBSD >= 199912) #define NET_SIZE_T socklen_t #endif -#endif #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT -#endif #include <sys/param.h> @@ -171,16 +151,7 @@ stat() properly */ #define CORE_EXPORT_NONSTD API_EXPORT_NONSTD #endif -/* On Darwin, symbols that conflict with loaded dylibs - * (eg. System framework) need to be declared as private symbols with - * __private_extern__. - * For other systems, make that a no-op. - */ -#if defined(DARWIN) && defined(__DYNAMIC__) -#define ap_private_extern __private_extern__ -#else #define ap_private_extern -#endif /* * The particular directory style your system supports. If you have dirent.h @@ -222,7 +193,7 @@ stat() properly */ #include <errno.h> #include <memory.h> -#if defined(WIN32) || defined(USE_HSREGEX) +#if defined(USE_HSREGEX) #include "hsregex.h" #else #include <regex.h> @@ -230,9 +201,6 @@ stat() properly */ #include <sys/resource.h> #include <sys/mman.h> -#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) -#define MAP_ANON MAP_ANONYMOUS -#endif /* A USE_FOO_SERIALIZED_ACCEPT implies a HAVE_FOO_SERIALIZED_ACCEPT */ #if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && !defined(HAVE_SYSVSEM_SERIALIZED_ACCEPT) @@ -259,7 +227,6 @@ stat() properly */ /* * Replace signal function with sigaction equivalent */ -#ifndef NO_USE_SIGACTION typedef void Sigfunc(int); #if defined(SIG_IGN) && !defined(SIG_ERR) @@ -274,7 +241,6 @@ typedef void Sigfunc(int); #endif #define signal(s,f) ap_signal(s,f) Sigfunc *signal(int signo, Sigfunc * func); -#endif #include <setjmp.h> @@ -361,13 +327,6 @@ Sigfunc *signal(int signo, Sigfunc * func); #define NET_SIZE_T int #endif -/* Linux defines __WCOREDUMP, but doesn't define WCOREDUMP unless __USE_BSD - * is in use... we'd prefer to just use WCOREDUMP everywhere. - */ -#if defined(__WCOREDUMP) && !defined(WCOREDUMP) -#define WCOREDUMP __WCOREDUMP -#endif - /* The assumption is that when the functions are missing, * then there's no matching prototype available either. * Declare what is needed exactly as the replacement routines implement it. diff --git a/usr.sbin/httpd/src/include/buff.h b/usr.sbin/httpd/src/include/buff.h index 78319c53a4b..6345c6beb13 100644 --- a/usr.sbin/httpd/src/include/buff.h +++ b/usr.sbin/httpd/src/include/buff.h @@ -63,10 +63,6 @@ extern "C" { #endif -#ifdef B_SFIO -#include "sfio.h" -#endif - #include <stdarg.h> /* Reading is buffered */ @@ -120,25 +116,11 @@ struct buff_struct { ap_ctx *ctx; -#ifdef B_SFIO - Sfio_t *sf_in; - Sfio_t *sf_out; -#endif - void *callback_data; void (*filter_callback)(BUFF *, const void *, int ); }; -#ifdef B_SFIO -typedef struct { - Sfdisc_t disc; - BUFF *buff; -} apache_sfio; - -extern Sfdisc_t *bsfio_new(pool *p, BUFF *b); -#endif - /* Options to bset/getopt */ #define BO_BYTECT (1) diff --git a/usr.sbin/httpd/src/include/http_conf_globals.h b/usr.sbin/httpd/src/include/http_conf_globals.h index 56acdfba357..0b3f7bb7c43 100644 --- a/usr.sbin/httpd/src/include/http_conf_globals.h +++ b/usr.sbin/httpd/src/include/http_conf_globals.h @@ -73,9 +73,6 @@ extern int ap_docrootcheck; extern API_VAR_EXPORT uid_t ap_user_id; extern API_VAR_EXPORT char *ap_user_name; extern API_VAR_EXPORT gid_t ap_group_id; -#ifdef MULTIPLE_GROUPS -extern gid_t group_id_list[NGROUPS_MAX]; -#endif extern API_VAR_EXPORT int ap_max_requests_per_child; extern API_VAR_EXPORT int ap_threads_per_child; extern API_VAR_EXPORT int ap_excess_requests_per_child; @@ -87,9 +84,6 @@ extern API_VAR_EXPORT int ap_daemons_max_free; extern API_VAR_EXPORT int ap_daemons_limit; extern API_VAR_EXPORT int ap_suexec_enabled; extern API_VAR_EXPORT int ap_listenbacklog; -#ifdef SO_ACCEPTFILTER -extern int ap_acceptfilter; -#endif extern int ap_dump_settings; extern API_VAR_EXPORT int ap_extended_status; extern API_VAR_EXPORT ap_ctx *ap_global_ctx; diff --git a/usr.sbin/httpd/src/include/http_core.h b/usr.sbin/httpd/src/include/http_core.h index 29a23f2e62d..a3f309594a5 100644 --- a/usr.sbin/httpd/src/include/http_core.h +++ b/usr.sbin/httpd/src/include/http_core.h @@ -277,15 +277,9 @@ typedef struct { char *add_default_charset_name; /* System Resource Control */ -#ifdef RLIMIT_CPU struct rlimit *limit_cpu; -#endif -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) struct rlimit *limit_mem; -#endif -#ifdef RLIMIT_NPROC struct rlimit *limit_nproc; -#endif unsigned long limit_req_body; /* limit on bytes in request msg body */ /* logging options */ diff --git a/usr.sbin/httpd/src/include/httpd.h b/usr.sbin/httpd/src/include/httpd.h index 405e59a401e..3a968b81be3 100644 --- a/usr.sbin/httpd/src/include/httpd.h +++ b/usr.sbin/httpd/src/include/httpd.h @@ -1083,15 +1083,11 @@ extern API_VAR_EXPORT time_t ap_restart_time; * can't be allocated above this number then it will remain in the "slack" * area. * - * Only the low slack line is used by default. If HIGH_SLACK_LINE is defined - * then an attempt is also made to keep all non-FILE * files above the high - * slack line. This is to work around a Solaris C library limitation, where it - * uses an unsigned char to store the file descriptor. + * Only the low slack line is used by default. */ #ifndef LOW_SLACK_LINE #define LOW_SLACK_LINE 15 #endif -/* #define HIGH_SLACK_LINE 255 */ /* * The ap_slack() function takes a fd, and tries to move it above the indicated @@ -1112,13 +1108,7 @@ API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) __attribute__((noreturn)); #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__)) -/* The optimized timeout code only works if we're not MULTITHREAD and we're - * also not using a scoreboard file - */ -#if !defined (MULTITHREAD) && \ - (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD)) #define OPTIMIZE_TIMEOUTS -#endif /* A set of flags which indicate places where the server should raise(SIGSTOP). * This is useful for debugging, because you can then attach to that process diff --git a/usr.sbin/httpd/src/include/scoreboard.h b/usr.sbin/httpd/src/include/scoreboard.h index e865f04ab6e..de6eb0174d3 100644 --- a/usr.sbin/httpd/src/include/scoreboard.h +++ b/usr.sbin/httpd/src/include/scoreboard.h @@ -126,10 +126,8 @@ typedef int ap_generation_t; /* stuff which the children generally write, and the parent mainly reads */ typedef struct { -#ifdef OPTIMIZE_TIMEOUTS vtime_t cur_vtime; /* the child's current vtime */ unsigned short timeout_len; /* length of the timeout */ -#endif unsigned char status; unsigned long access_count; unsigned long bytes_served; @@ -140,9 +138,6 @@ typedef struct { struct timeval start_time; struct timeval stop_time; struct tms times; -#ifndef OPTIMIZE_TIMEOUTS - time_t last_used; -#endif char client[32]; /* Keep 'em small... */ char request[64]; /* We just want an idea... */ server_rec *vhostrec; /* What virtual host is being accessed? */ @@ -157,10 +152,8 @@ typedef struct { /* stuff which the parent generally writes and the children rarely read */ typedef struct { pid_t pid; -#ifdef OPTIMIZE_TIMEOUTS time_t last_rtime; /* time(0) of the last change */ vtime_t last_vtime; /* the last vtime the parent has seen */ -#endif ap_generation_t generation; /* generation of this child */ } parent_score; diff --git a/usr.sbin/httpd/src/lib/expat-lite/xmlparse.c b/usr.sbin/httpd/src/lib/expat-lite/xmlparse.c index 5e92a8397a6..578f95e1fe0 100644 --- a/usr.sbin/httpd/src/lib/expat-lite/xmlparse.c +++ b/usr.sbin/httpd/src/lib/expat-lite/xmlparse.c @@ -396,15 +396,6 @@ typedef struct { #define hadExternalDoctype (((Parser *)parser)->m_hadExternalDoctype) #define namespaceSeparator (((Parser *)parser)->m_namespaceSeparator) -#ifdef _MSC_VER -#ifdef _DEBUG -Parser *asParser(XML_Parser parser) -{ - return parser; -} -#endif -#endif - XML_Parser XML_ParserCreate(const XML_Char *encodingName) { XML_Parser parser = malloc(sizeof(Parser)); diff --git a/usr.sbin/httpd/src/lib/expat-lite/xmltok.c b/usr.sbin/httpd/src/lib/expat-lite/xmltok.c index f0570d81456..f0c15b1b7cf 100644 --- a/usr.sbin/httpd/src/lib/expat-lite/xmltok.c +++ b/usr.sbin/httpd/src/lib/expat-lite/xmltok.c @@ -139,13 +139,6 @@ int utf8_isInvalid4(const ENCODING *enc, const char *p) struct normal_encoding { ENCODING enc; unsigned char type[256]; -#ifdef XML_MIN_SIZE - int (*byteType)(const ENCODING *, const char *); - int (*isNameMin)(const ENCODING *, const char *); - int (*isNmstrtMin)(const ENCODING *, const char *); - int (*byteToAscii)(const ENCODING *, const char *); - int (*charMatches)(const ENCODING *, const char *, int); -#endif /* XML_MIN_SIZE */ int (*isName2)(const ENCODING *, const char *); int (*isName3)(const ENCODING *, const char *); int (*isName4)(const ENCODING *, const char *); @@ -157,21 +150,8 @@ struct normal_encoding { int (*isInvalid4)(const ENCODING *, const char *); }; -#ifdef XML_MIN_SIZE - -#define STANDARD_VTABLE(E) \ - E ## byteType, \ - E ## isNameMin, \ - E ## isNmstrtMin, \ - E ## byteToAscii, \ - E ## charMatches, - -#else - #define STANDARD_VTABLE(E) /* as nothing */ -#endif - #define NORMAL_VTABLE(E) \ E ## isName2, \ E ## isName3, \ @@ -187,44 +167,16 @@ static int checkCharRefNumber(int); #include "xmltok_impl.h" -#ifdef XML_MIN_SIZE -#define sb_isNameMin isNever -#define sb_isNmstrtMin isNever -#endif -#ifdef XML_MIN_SIZE -#define MINBPC(enc) ((enc)->minBytesPerChar) -#else /* minimum bytes per character */ #define MINBPC(enc) 1 -#endif #define SB_BYTE_TYPE(enc, p) \ (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) -#ifdef XML_MIN_SIZE -static -int sb_byteType(const ENCODING *enc, const char *p) -{ - return SB_BYTE_TYPE(enc, p); -} -#define BYTE_TYPE(enc, p) \ - (((const struct normal_encoding *)(enc))->byteType(enc, p)) -#else #define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) -#endif -#ifdef XML_MIN_SIZE -#define BYTE_TO_ASCII(enc, p) \ - (((const struct normal_encoding *)(enc))->byteToAscii(enc, p)) -static -int sb_byteToAscii(const ENCODING *enc, const char *p) -{ - return *p; -} -#else #define BYTE_TO_ASCII(enc, p) (*p) -#endif #define IS_NAME_CHAR(enc, p, n) \ (((const struct normal_encoding *)(enc))->isName ## n(enc, p)) @@ -233,28 +185,11 @@ int sb_byteToAscii(const ENCODING *enc, const char *p) #define IS_INVALID_CHAR(enc, p, n) \ (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p)) -#ifdef XML_MIN_SIZE -#define IS_NAME_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNameMin(enc, p)) -#define IS_NMSTRT_CHAR_MINBPC(enc, p) \ - (((const struct normal_encoding *)(enc))->isNmstrtMin(enc, p)) -#else #define IS_NAME_CHAR_MINBPC(enc, p) (0) #define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) -#endif -#ifdef XML_MIN_SIZE -#define CHAR_MATCHES(enc, p, c) \ - (((const struct normal_encoding *)(enc))->charMatches(enc, p, c)) -static -int sb_charMatches(const ENCODING *enc, const char *p, int c) -{ - return *p == c; -} -#else /* c is an ASCII character */ #define CHAR_MATCHES(enc, p, c) (*(p) == c) -#endif #define PREFIX(ident) normal_ ## ident #include "xmltok_impl.c" @@ -601,43 +536,6 @@ DEFINE_UTF16_TO_UTF16(big2_) #define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) -#ifdef XML_MIN_SIZE - -static -int little2_byteType(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TYPE(enc, p); -} - -static -int little2_byteToAscii(const ENCODING *enc, const char *p) -{ - return LITTLE2_BYTE_TO_ASCII(enc, p); -} - -static -int little2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return LITTLE2_CHAR_MATCHES(enc, p, c); -} - -static -int little2_isNameMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static -int little2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 - -#else /* not XML_MIN_SIZE */ - #undef PREFIX #define PREFIX(ident) little2_ ## ident #define MINBPC(enc) 2 @@ -662,8 +560,6 @@ int little2_isNmstrtMin(const ENCODING *enc, const char *p) #undef IS_NMSTRT_CHAR_MINBPC #undef IS_INVALID_CHAR -#endif /* not XML_MIN_SIZE */ - #ifdef XML_NS static const struct normal_encoding little2_encoding_ns = { @@ -740,43 +636,6 @@ static const struct normal_encoding internal_little2_encoding = { #define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) -#ifdef XML_MIN_SIZE - -static -int big2_byteType(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TYPE(enc, p); -} - -static -int big2_byteToAscii(const ENCODING *enc, const char *p) -{ - return BIG2_BYTE_TO_ASCII(enc, p); -} - -static -int big2_charMatches(const ENCODING *enc, const char *p, int c) -{ - return BIG2_CHAR_MATCHES(enc, p, c); -} - -static -int big2_isNameMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NAME_CHAR_MINBPC(enc, p); -} - -static -int big2_isNmstrtMin(const ENCODING *enc, const char *p) -{ - return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); -} - -#undef VTABLE -#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 - -#else /* not XML_MIN_SIZE */ - #undef PREFIX #define PREFIX(ident) big2_ ## ident #define MINBPC(enc) 2 @@ -801,8 +660,6 @@ int big2_isNmstrtMin(const ENCODING *enc, const char *p) #undef IS_NMSTRT_CHAR_MINBPC #undef IS_INVALID_CHAR -#endif /* not XML_MIN_SIZE */ - #ifdef XML_NS static const struct normal_encoding big2_encoding_ns = { diff --git a/usr.sbin/httpd/src/main/alloc.c b/usr.sbin/httpd/src/main/alloc.c index 38cd26c3a4d..87f9e397287 100644 --- a/usr.sbin/httpd/src/main/alloc.c +++ b/usr.sbin/httpd/src/main/alloc.c @@ -64,10 +64,8 @@ */ #include "httpd.h" -#ifdef EAPI #include "http_config.h" #include "http_conf_globals.h" -#endif #include "multithread.h" #include "http_log.h" @@ -125,9 +123,6 @@ #ifdef ALLOC_USE_MALLOC # error "sorry, no support for ALLOC_USE_MALLOC and POOL_DEBUG at the same time" #endif -#ifdef MULTITHREAD -# error "sorry, no support for MULTITHREAD and POOL_DEBUG at the same time" -#endif #endif #ifdef ALLOC_USE_MALLOC @@ -137,7 +132,7 @@ #define BLOCK_MINALLOC 0 #endif -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) static AP_MM *mm = NULL; #endif @@ -169,7 +164,7 @@ union block_hdr { char *endp; union block_hdr *next; char *first_avail; -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) int is_shm; #endif #ifdef POOL_DEBUG @@ -222,7 +217,7 @@ static ap_inline void debug_verify_filled(const char *ptr, /* Get a completely new block from the system pool. Note that we rely on malloc() to provide aligned memory. */ -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) static union block_hdr *malloc_block(int size, int is_shm) #else static union block_hdr *malloc_block(int size) @@ -242,7 +237,7 @@ static union block_hdr *malloc_block(int size) num_malloc_bytes += size + sizeof(union block_hdr); #endif request_size = size + sizeof(union block_hdr); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (is_shm) blok = (union block_hdr *)ap_mm_malloc(mm, request_size); else @@ -254,7 +249,7 @@ static union block_hdr *malloc_block(int size) exit(1); } debug_fill(blok, size + sizeof(union block_hdr)); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) blok->h.is_shm = is_shm; #endif blok->h.next = NULL; @@ -317,7 +312,7 @@ static void free_blocks(union block_hdr *blok) if (blok == NULL) return; /* Sanity check --- freeing empty pool? */ -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif @@ -367,7 +362,7 @@ static void free_blocks(union block_hdr *blok) #endif (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_unlock(mm); #endif @@ -379,7 +374,7 @@ static void free_blocks(union block_hdr *blok) * if necessary. Must be called with alarms blocked. */ -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) static union block_hdr *new_block(int min_size, int is_shm) #else static union block_hdr *new_block(int min_size) @@ -393,7 +388,7 @@ static union block_hdr *new_block(int min_size) */ while (blok != NULL) { -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm == is_shm && min_size + BLOCK_MINFREE <= blok->h.endp - blok->h.first_avail) { #else @@ -414,7 +409,7 @@ static union block_hdr *new_block(int min_size) /* Nope. */ min_size += BLOCK_MINFREE; -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC, is_shm); #else blok = malloc_block((min_size > BLOCK_MINALLOC) ? min_size : BLOCK_MINALLOC); @@ -468,7 +463,7 @@ struct pool { #ifdef POOL_DEBUG struct pool *joined; #endif -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) int is_shm; #endif }; @@ -485,7 +480,7 @@ static pool *permanent_pool; #define POOL_HDR_CLICKS (1 + ((sizeof(struct pool) - 1) / CLICK_SZ)) #define POOL_HDR_BYTES (POOL_HDR_CLICKS * CLICK_SZ) -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) static struct pool *make_sub_pool_internal(struct pool *p, int is_shm) #else API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) @@ -496,13 +491,13 @@ API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) ap_block_alarms(); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif (void) ap_acquire_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) blok = new_block(POOL_HDR_BYTES, is_shm); #else blok = new_block(POOL_HDR_BYTES); @@ -525,12 +520,12 @@ API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) p->sub_pools = new_pool; } -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) new_pool->is_shm = is_shm; #endif (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (is_shm) (void)ap_mm_unlock(mm); #endif @@ -539,7 +534,6 @@ API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) return new_pool; } -#if defined(EAPI) #if defined(EAPI_MM) API_EXPORT(struct pool *) ap_make_sub_pool(struct pool *p) { @@ -555,7 +549,6 @@ API_EXPORT(struct pool *) ap_make_shared_sub_pool(struct pool *p) return NULL; } #endif -#endif #ifdef POOL_DEBUG static void stack_var_init(char *s) @@ -571,12 +564,10 @@ static void stack_var_init(char *s) } #endif -#if defined(EAPI) int ap_shared_pool_possible(void) { return ap_mm_useable(); } -#endif #ifdef ALLOC_STATS static void dump_stats(void) @@ -610,7 +601,6 @@ API_EXPORT(pool *) ap_init_alloc(void) return permanent_pool; } -#if defined(EAPI) void ap_init_alloc_shared(int early) { #if defined(EAPI_MM) @@ -656,7 +646,6 @@ void ap_kill_alloc_shared(void) #endif /* EAPI_MM */ return; } -#endif /* EAPI */ void ap_cleanup_alloc(void) { @@ -668,7 +657,7 @@ API_EXPORT(void) ap_clear_pool(struct pool *a) { ap_block_alarms(); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif @@ -676,7 +665,7 @@ API_EXPORT(void) ap_clear_pool(struct pool *a) while (a->sub_pools) ap_destroy_pool(a->sub_pools); (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_unlock(mm); #endif @@ -713,7 +702,7 @@ API_EXPORT(void) ap_destroy_pool(pool *a) ap_block_alarms(); ap_clear_pool(a); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif @@ -727,7 +716,7 @@ API_EXPORT(void) ap_destroy_pool(pool *a) a->sub_next->sub_prev = a->sub_prev; } (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_unlock(mm); #endif @@ -745,7 +734,6 @@ API_EXPORT(long) ap_bytes_in_free_blocks(void) return bytes_in_block_list(block_freelist); } -#if defined(EAPI) API_EXPORT(int) ap_acquire_pool(pool *p, ap_pool_lock_mode mode) { #if defined(EAPI_MM) @@ -767,7 +755,6 @@ API_EXPORT(int) ap_release_pool(pool *p) return 1; #endif } -#endif /* EAPI */ /***************************************************************** * POOL_DEBUG support @@ -934,13 +921,13 @@ API_EXPORT(void *) ap_palloc(struct pool *a, int reqsize) ap_block_alarms(); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif (void) ap_acquire_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) blok = new_block(size, a->is_shm); #else blok = new_block(size); @@ -950,12 +937,12 @@ API_EXPORT(void *) ap_palloc(struct pool *a, int reqsize) #ifdef POOL_DEBUG blok->h.owning_pool = a; #endif -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) blok->h.is_shm = a->is_shm; #endif (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (a->is_shm) (void)ap_mm_unlock(mm); #endif @@ -1075,7 +1062,7 @@ static int psprintf_flush(ap_vformatter_buff *vbuff) size = cur_len << 1; if (size < AP_PSPRINTF_MIN_SIZE) size = AP_PSPRINTF_MIN_SIZE; -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (ps->block->h.is_shm) ptr = ap_mm_realloc(ps->base, size); else @@ -1103,18 +1090,18 @@ static int psprintf_flush(ap_vformatter_buff *vbuff) size = AP_PSPRINTF_MIN_SIZE; /* must try another blok */ -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif (void) ap_acquire_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) nblok = new_block(size, blok->h.is_shm); #else nblok = new_block(size); #endif (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_unlock(mm); #endif @@ -1126,7 +1113,7 @@ static int psprintf_flush(ap_vformatter_buff *vbuff) /* did we allocate the current blok? if so free it up */ if (ps->got_a_new_block) { debug_fill(blok->h.first_avail, blok->h.endp - blok->h.first_avail); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_lock(mm, AP_MM_LOCK_RW); #endif @@ -1134,7 +1121,7 @@ static int psprintf_flush(ap_vformatter_buff *vbuff) blok->h.next = block_freelist; block_freelist = blok; (void) ap_release_mutex(alloc_mutex); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (blok->h.is_shm) (void)ap_mm_unlock(mm); #endif @@ -1156,7 +1143,7 @@ API_EXPORT(char *) ap_pvsprintf(pool *p, const char *fmt, va_list ap) void *ptr; ap_block_alarms(); -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (p->is_shm) ps.base = ap_mm_malloc(mm, 512); else @@ -1173,7 +1160,7 @@ API_EXPORT(char *) ap_pvsprintf(pool *p, const char *fmt, va_list ap) *ps.vbuff.curpos++ = '\0'; ptr = ps.base; /* shrink */ -#if defined(EAPI) && defined(EAPI_MM) +#if defined(EAPI_MM) if (p->is_shm) ptr = ap_mm_realloc(ptr, (char *)ps.vbuff.curpos - (char *)ptr); else @@ -2018,7 +2005,6 @@ API_EXPORT_NONSTD(void) ap_null_cleanup(void *data) int ap_close_fd_on_exec(int fd) { -#if defined(F_SETFD) && defined(FD_CLOEXEC) /* Protect the fd so that it will not be inherited by child processes */ if(fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) { ap_log_error(APLOG_MARK, APLOG_ERR, NULL, @@ -2027,9 +2013,6 @@ int ap_close_fd_on_exec(int fd) } return 1; -#else - return 0; -#endif } static void fd_cleanup(void *fdv) @@ -2594,14 +2577,12 @@ static void free_proc_chain(struct process_chain *procs) * don't waste any more cycles doing whatever it is that they shouldn't * be doing anymore. */ -#ifndef NEED_WAITPID /* Pick up all defunct processes */ for (p = procs; p; p = p->next) { if (waitpid(p->pid, (int *) 0, WNOHANG) > 0) { p->kill_how = kill_never; } } -#endif for (p = procs; p; p = p->next) { if ((p->kill_how == kill_after_timeout) diff --git a/usr.sbin/httpd/src/main/buff.c b/usr.sbin/httpd/src/main/buff.c index ec33172b0b6..40765b61173 100644 --- a/usr.sbin/httpd/src/main/buff.c +++ b/usr.sbin/httpd/src/main/buff.c @@ -142,12 +142,7 @@ static int ap_write(BUFF *fb, const void *buf, int nbyte) int rv; if (!ap_hook_call("ap::buff::write", &rv, fb, buf, nbyte)) -#if defined (B_SFIO) - rv = sfwrite(fb->sf_out, buf, nbyte); -#else rv = write(fb->fd, buf, nbyte); -#endif - return rv; } @@ -210,15 +205,6 @@ API_EXPORT(BUFF *) ap_bcreate(pool *p, int flags) fb->fd = -1; fb->fd_in = -1; -#ifdef B_SFIO - fb->sf_in = NULL; - fb->sf_out = NULL; - fb->sf_in = sfnew(fb->sf_in, NIL(Void_t *), - (size_t) SF_UNBOUND, 0, SF_READ); - fb->sf_out = sfnew(fb->sf_out, NIL(Void_t *), - (size_t) SF_UNBOUND, 1, SF_WRITE); -#endif - fb->callback_data = NULL; fb->filter_callback = NULL; @@ -370,16 +356,7 @@ API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction) int fd; fd = (direction == B_RD) ? fb->fd_in : fb->fd; -#if defined(O_NONBLOCK) return fcntl(fd, F_SETFL, O_NONBLOCK); -#elif defined(O_NDELAY) - return fcntl(fd, F_SETFL, O_NDELAY); -#elif defined(FNDELAY) - return fcntl(fd, F_SETFL, FNDELAY); -#else - /* XXXX: this breaks things, but an alternative isn't obvious...*/ - return 0; -#endif } API_EXPORT(int) ap_bfileno(BUFF *fb, int direction) @@ -394,16 +371,7 @@ API_EXPORT(int) ap_bfileno(BUFF *fb, int direction) * return code is like read() except EINTR is eliminated. */ - -#if !defined (B_SFIO) || defined (WIN32) #define saferead saferead_guts -#else -static int saferead(BUFF *fb, char *buf, int nbyte) -{ - return sfread(fb->sf_in, buf, nbyte); -} -#endif - /* Test the descriptor and flush the output buffer if it looks like * we will block on the next read. @@ -451,42 +419,6 @@ static ap_inline int saferead_guts(BUFF *fb, void *buf, int nbyte) return (rv); } -#ifdef B_SFIO -int bsfio_read(Sfio_t * f, char *buf, int nbyte, apache_sfio *disc) -{ - int rv; - BUFF *fb = disc->buff; - - rv = saferead_guts(fb, buf, nbyte); - - buf[rv] = '\0'; - f->next = 0; - - return (rv); -} - -int bsfio_write(Sfio_t * f, char *buf, int nbyte, apache_sfio *disc) -{ - return ap_write(disc->buff, buf, nbyte); -} - -Sfdisc_t *bsfio_new(pool *p, BUFF *b) -{ - apache_sfio *disc; - - if (!(disc = (apache_sfio *) ap_palloc(p, sizeof(apache_sfio)))) - return (Sfdisc_t *) disc; - - disc->disc.readf = (Sfread_f) bsfio_read; - disc->disc.writef = (Sfwrite_f) bsfio_write; - disc->disc.seekf = (Sfseek_f) NULL; - disc->disc.exceptf = (Sfexcept_f) NULL; - disc->buff = b; - - return (Sfdisc_t *) disc; -} -#endif - /* A wrapper around saferead which does error checking and EOF checking * yeah, it's confusing, this calls saferead, which calls buff_read... @@ -1177,11 +1109,6 @@ API_EXPORT(int) ap_bclose(BUFF *fb) fb->fd = -1; fb->fd_in = -1; -#ifdef B_SFIO - sfclose(fb->sf_in); - sfclose(fb->sf_out); -#endif - if (rc1 != 0) return rc1; else if (rc2 != 0) diff --git a/usr.sbin/httpd/src/main/http_config.c b/usr.sbin/httpd/src/main/http_config.c index 6ed4c3114f9..413b5be3d1d 100644 --- a/usr.sbin/httpd/src/main/http_config.c +++ b/usr.sbin/httpd/src/main/http_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_config.c,v 1.15 2004/12/02 19:42:47 henning Exp $ */ +/* $OpenBSD: http_config.c,v 1.16 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -587,7 +587,6 @@ API_EXPORT(void) ap_add_module(module *m) if (strrchr(m->name, '\\')) m->name = 1 + strrchr(m->name, '\\'); -#ifdef EAPI /* * Invoke the `add_module' hook inside the now existing set * of modules to let them all now that this module was added. @@ -599,7 +598,6 @@ API_EXPORT(void) ap_add_module(module *m) if (m2->add_module != NULL) (*m2->add_module)(m); } -#endif /* EAPI */ } /* @@ -614,7 +612,6 @@ API_EXPORT(void) ap_remove_module(module *m) { module *modp; -#ifdef EAPI /* * Invoke the `remove_module' hook inside the now existing * set of modules to let them all now that this module is @@ -627,7 +624,6 @@ API_EXPORT(void) ap_remove_module(module *m) if (m2->remove_module != NULL) (*m2->remove_module)(m); } -#endif /* EAPI */ modp = top_module; if (modp == m) { @@ -1018,7 +1014,6 @@ CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, cons const command_rec *cmd; module *mod = top_module; -#ifdef EAPI /* * Invoke the `rewrite_command' of modules to allow * they to rewrite the directive line before we @@ -1037,7 +1032,6 @@ CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, cons } } } -#endif /* EAPI */ if ((l[0] == '#') || (!l[0])) return NULL; @@ -1440,7 +1434,6 @@ CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname, { server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec)); -#ifdef RLIMIT_NOFILE struct rlimit limits; getrlimit(RLIMIT_NOFILE, &limits); @@ -1451,7 +1444,6 @@ CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname, fprintf(stderr, "Cannot exceed hard limit for open files"); } } -#endif s->server_admin = NULL; s->server_hostname = NULL; @@ -1482,9 +1474,7 @@ CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname, s->limit_req_fieldsize = main_server->limit_req_fieldsize; s->limit_req_fields = main_server->limit_req_fields; -#ifdef EAPI s->ctx = ap_ctx_new(p); -#endif /* EAPI */ *ps = s; @@ -1600,9 +1590,7 @@ static server_rec *init_server_config(pool *p) s->module_config = create_server_config(p, s); s->lookup_defaults = create_default_per_dir_config(p); -#ifdef EAPI s->ctx = ap_ctx_new(p); -#endif /* EAPI */ return s; } @@ -1686,12 +1674,8 @@ API_EXPORT(void) ap_child_exit_modules(pool *p, server_rec *s) { module *m; -#ifdef SIGHUP signal(SIGHUP, SIG_IGN); -#endif -#ifdef SIGUSR1 signal(SIGUSR1, SIG_IGN); -#endif for (m = top_module; m; m = m->next) if (m->child_exit) diff --git a/usr.sbin/httpd/src/main/http_core.c b/usr.sbin/httpd/src/main/http_core.c index 62794a0cf9e..0ebf2a4fe00 100644 --- a/usr.sbin/httpd/src/main/http_core.c +++ b/usr.sbin/httpd/src/main/http_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_core.c,v 1.19 2004/12/02 19:42:47 henning Exp $ */ +/* $OpenBSD: http_core.c,v 1.20 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -59,7 +59,6 @@ */ #define CORE_PRIVATE -#define ADD_EBCDICCONVERT_DEBUG_HEADER 0 #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -74,7 +73,6 @@ #include "scoreboard.h" #include "fnmatch.h" -#ifdef USE_MMAP_FILES #include <sys/mman.h> /* mmap support for static files based on ideas from John Heidemann's @@ -89,7 +87,6 @@ #ifndef MMAP_THRESHOLD #define MMAP_THRESHOLD 1 #endif -#endif #ifndef MMAP_LIMIT #define MMAP_LIMIT (4*1024*1024) #endif @@ -136,15 +133,9 @@ static void *create_core_dir_config(pool *a, char *dir) conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */ conf->satisfy = SATISFY_NOSPEC; -#ifdef RLIMIT_CPU conf->limit_cpu = NULL; -#endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) conf->limit_mem = NULL; -#endif -#ifdef RLIMIT_NPROC conf->limit_nproc = NULL; -#endif conf->limit_req_body = 0; conf->sec = ap_make_array(a, 2, sizeof(void *)); @@ -256,21 +247,15 @@ static void *merge_core_dir_configs(pool *a, void *basev, void *newv) conf->use_canonical_name = new->use_canonical_name; } -#ifdef RLIMIT_CPU if (new->limit_cpu) { conf->limit_cpu = new->limit_cpu; } -#endif -#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS) if (new->limit_mem) { conf->limit_mem = new->limit_mem; } -#endif -#ifdef RLIMIT_NPROC if (new->limit_nproc) { conf->limit_nproc = new->limit_nproc; } -#endif if (new->limit_req_body) { conf->limit_req_body = new->limit_req_body; @@ -408,24 +393,8 @@ CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config) * See directory_walk(). */ -#if defined(HAVE_DRIVE_LETTERS) -#define IS_SPECIAL(entry_core) \ - ((entry_core)->r != NULL \ - || ((entry_core)->d[0] != '/' && (entry_core)->d[1] != ':')) -#elif defined(NETWARE) -/* XXX: Fairly certain this is correct... '/' must prefix the path - * or else in the case xyz:/ or abc/xyz:/, '/' must follow the ':'. - * If there is no leading '/' or embedded ':/', then we are special. - */ -#define IS_SPECIAL(entry_core) \ - ((entry_core)->r != NULL \ - || ((entry_core)->d[0] != '/' \ - && strchr((entry_core)->d, ':') \ - && *(strchr((entry_core)->d, ':') + 1) != '/')) -#else #define IS_SPECIAL(entry_core) \ ((entry_core)->r != NULL || (entry_core)->d[0] != '/') -#endif /* We need to do a stable sort, qsort isn't stable. So to make it stable * we'll be maintaining the original index into the list, and using it @@ -1362,18 +1331,6 @@ static const char *dirsection(cmd_parms *cmd, void *dummy, const char *arg) ap_server_strip_chroot(cmd->path, 1); r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE); } -#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) - else if (strcmp(cmd->path, "/") == 0) { - /* Treat 'default' path / as an inalienable root */ - cmd->path = ap_pstrdup(cmd->pool, cmd->path); - } -#endif -#if defined(HAVE_UNC_PATHS) - else if (strcmp(cmd->path, "//") == 0) { - /* Treat UNC path // as an inalienable root */ - cmd->path = ap_pstrdup(cmd->pool, cmd->path); - } -#endif else { /* Ensure that the pathname is canonical */ cmd->path = ap_os_canonical_filename(cmd->pool, cmd->path); @@ -1915,7 +1872,7 @@ static const char *set_user(cmd_parms *cmd, void *dummy, char *arg) "requires SUEXEC wrapper.\n"); } } -#if !defined (BIG_SECURITY_HOLE) && !defined (OS2) +#if !defined (BIG_SECURITY_HOLE) if (cmd->server->server_uid == 0) { fprintf(stderr, "Error:\tApache has not been designed to serve pages while\n" @@ -2280,7 +2237,6 @@ static const char *set_excess_requests(cmd_parms *cmd, void *dummy, char *arg) } -#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) static void set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char *arg, const char * arg2, int type) { @@ -2334,50 +2290,27 @@ static void set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char *arg, } } } -#endif - -#if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC) -static const char *no_set_limit(cmd_parms *cmd, core_dir_config *conf, - char *arg, char *arg2) -{ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, cmd->server, - "%s not supported on this platform", cmd->cmd->name); - return NULL; -} -#endif -#ifdef RLIMIT_CPU static const char *set_limit_cpu(cmd_parms *cmd, core_dir_config *conf, char *arg, char *arg2) { set_rlimit(cmd, &conf->limit_cpu, arg, arg2, RLIMIT_CPU); return NULL; } -#endif -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) static const char *set_limit_mem(cmd_parms *cmd, core_dir_config *conf, char *arg, char * arg2) { -#if defined(RLIMIT_AS) - set_rlimit(cmd, &conf->limit_mem, arg, arg2 ,RLIMIT_AS); -#elif defined(RLIMIT_DATA) set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_DATA); -#elif defined(RLIMIT_VMEM) - set_rlimit(cmd, &conf->limit_mem, arg, arg2, RLIMIT_VMEM); -#endif return NULL; } -#endif -#ifdef RLIMIT_NPROC static const char *set_limit_nproc(cmd_parms *cmd, core_dir_config *conf, char *arg, char * arg2) { set_rlimit(cmd, &conf->limit_nproc, arg, arg2, RLIMIT_NPROC); return NULL; } -#endif static const char *set_bind_address(cmd_parms *cmd, void *dummy, char *arg) { @@ -2400,9 +2333,6 @@ static const char *set_bind_address(cmd_parms *cmd, void *dummy, char *arg) */ static const char *set_acceptfilter(cmd_parms *cmd, void *dummy, int flag) { -#ifdef SO_ACCEPTFILTER - ap_acceptfilter = flag; -#endif return NULL; } @@ -3179,25 +3109,13 @@ static const command_rec core_cmds[] = { { "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1, "Maximum number of requests a particular child serves before dying." }, { "RLimitCPU", -#ifdef RLIMIT_CPU set_limit_cpu, (void*)XtOffsetOf(core_dir_config, limit_cpu), -#else - no_set_limit, NULL, -#endif OR_ALL, TAKE12, "Soft/hard limits for max CPU usage in seconds" }, { "RLimitMEM", -#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined (RLIMIT_AS) set_limit_mem, (void*)XtOffsetOf(core_dir_config, limit_mem), -#else - no_set_limit, NULL, -#endif OR_ALL, TAKE12, "Soft/hard limits for max memory usage per process" }, { "RLimitNPROC", -#ifdef RLIMIT_NPROC set_limit_nproc, (void*)XtOffsetOf(core_dir_config, limit_nproc), -#else - no_set_limit, NULL, -#endif OR_ALL, TAKE12, "soft/hard limits for max number of processes per uid" }, { "BindAddress", set_bind_address, NULL, RSRC_CONF, TAKE1, "'*', a numeric IP address, or the name of a host with a unique IP address"}, @@ -3218,16 +3136,10 @@ static const command_rec core_cmds[] = { "Maximum length of the queue of pending connections, as used by listen(2)" }, { "AcceptFilter", set_acceptfilter, NULL, RSRC_CONF, FLAG, "Switch AcceptFiltering on/off (default is " -#ifdef AP_ACCEPTFILTER_OFF - "off" -#else "on" -#endif ")." -#ifndef SO_ACCEPTFILTER "This feature is currently not compiled in; so this directive " "is ignored." -#endif }, { "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1, "The location of the directory Apache changes to before dumping core" }, @@ -3257,24 +3169,8 @@ static const command_rec core_cmds[] = { "Enable the setting of SysV shared memory scoreboard uid/gid to User/Group" }, { "AcceptMutex", set_accept_mutex, NULL, RSRC_CONF, TAKE1, "Serialized Accept Mutex; the methods " -#ifdef HAVE_USLOCK_SERIALIZED_ACCEPT - "'uslock' " -#endif -#ifdef HAVE_PTHREAD_SERIALIZED_ACCEPT - "'pthread' " -#endif -#ifdef HAVE_SYSVSEM_SERIALIZED_ACCEPT "'sysvsem' " -#endif -#ifdef HAVE_FCNTL_SERIALIZED_ACCEPT - "'fcntl' " -#endif -#ifdef HAVE_FLOCK_SERIALIZED_ACCEPT "'flock' " -#endif -#ifdef HAVE_NONE_SERIALIZED_ACCEPT - "'none' " -#endif "are compiled in" }, @@ -3336,7 +3232,6 @@ static int core_translate(request_rec *r) static int do_nothing(request_rec *r) { return OK; } -#ifdef USE_MMAP_FILES struct mmap_rec { void *mm; size_t length; @@ -3352,7 +3247,6 @@ static void mmap_cleanup(void *mmv) (long) mmd->length, (long) mmd->mm); } } -#endif /* * Default handler for MIME types without other handlers. Only GET @@ -3368,9 +3262,7 @@ static int default_handler(request_rec *r) (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); int rangestatus, errstatus; FILE *f; -#ifdef USE_MMAP_FILES caddr_t mm; -#endif /* This handler has no use for a request body (yet), but we still * need to read and discard it if the client sent one. @@ -3422,7 +3314,6 @@ static int default_handler(request_rec *r) return errstatus; } -#ifdef USE_MMAP_FILES ap_block_alarms(); if ((r->finfo.st_size >= MMAP_THRESHOLD) && (r->finfo.st_size < MMAP_LIMIT) @@ -3442,7 +3333,6 @@ static int default_handler(request_rec *r) if (mm == (caddr_t)-1) { ap_unblock_alarms(); -#endif if (d->content_md5 & 1) { ap_table_setn(r->headers_out, "Content-MD5", @@ -3476,7 +3366,6 @@ static int default_handler(request_rec *r) } } -#ifdef USE_MMAP_FILES } else { struct mmap_rec *mmd; @@ -3511,7 +3400,6 @@ static int default_handler(request_rec *r) } } } -#endif ap_pfclose(r->pool, f); return OK; diff --git a/usr.sbin/httpd/src/main/http_log.c b/usr.sbin/httpd/src/main/http_log.c index 0ec9bd7af02..118698ebcc1 100644 --- a/usr.sbin/httpd/src/main/http_log.c +++ b/usr.sbin/httpd/src/main/http_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_log.c,v 1.16 2004/12/02 19:42:47 henning Exp $ */ +/* $OpenBSD: http_log.c,v 1.17 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -81,70 +81,29 @@ typedef struct { int t_val; } TRANS; -#ifdef HAVE_SYSLOG - static const TRANS facilities[] = { {"auth", LOG_AUTH}, -#ifdef LOG_AUTHPRIV {"authpriv",LOG_AUTHPRIV}, -#endif -#ifdef LOG_CRON {"cron", LOG_CRON}, -#endif -#ifdef LOG_DAEMON {"daemon", LOG_DAEMON}, -#endif -#ifdef LOG_FTP {"ftp", LOG_FTP}, -#endif -#ifdef LOG_KERN {"kern", LOG_KERN}, -#endif -#ifdef LOG_LPR {"lpr", LOG_LPR}, -#endif -#ifdef LOG_MAIL {"mail", LOG_MAIL}, -#endif -#ifdef LOG_NEWS {"news", LOG_NEWS}, -#endif -#ifdef LOG_SYSLOG {"syslog", LOG_SYSLOG}, -#endif -#ifdef LOG_USER {"user", LOG_USER}, -#endif -#ifdef LOG_UUCP {"uucp", LOG_UUCP}, -#endif -#ifdef LOG_LOCAL0 {"local0", LOG_LOCAL0}, -#endif -#ifdef LOG_LOCAL1 {"local1", LOG_LOCAL1}, -#endif -#ifdef LOG_LOCAL2 {"local2", LOG_LOCAL2}, -#endif -#ifdef LOG_LOCAL3 {"local3", LOG_LOCAL3}, -#endif -#ifdef LOG_LOCAL4 {"local4", LOG_LOCAL4}, -#endif -#ifdef LOG_LOCAL5 {"local5", LOG_LOCAL5}, -#endif -#ifdef LOG_LOCAL6 {"local6", LOG_LOCAL6}, -#endif -#ifdef LOG_LOCAL7 {"local7", LOG_LOCAL7}, -#endif {NULL, -1}, }; -#endif static const TRANS priorities[] = { {"emerg", APLOG_EMERG}, @@ -167,10 +126,8 @@ static int error_log_child(void *cmd, child_info *pinfo) int child_pid = 0; ap_cleanup_for_exec(); -#ifdef SIGHUP /* No concept of a child process on Win32 */ signal(SIGHUP, SIG_IGN); -#endif /* ndef SIGHUP */ execl(SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, (char *)NULL); exit(1); /* NOT REACHED */ @@ -193,7 +150,6 @@ static void open_error_log(server_rec *s, pool *p) s->error_log = dummy; } -#ifdef HAVE_SYSLOG else if (!strncasecmp(s->error_fname, "syslog", 6)) { if ((fname = strchr(s->error_fname, ':'))) { const TRANS *fac; @@ -213,7 +169,6 @@ static void open_error_log(server_rec *s, pool *p) s->error_log = NULL; } -#endif else { fname = ap_server_root_relative(p, s->error_fname); if (!(s->error_log = ap_pfopen(p, fname, "a"))) { @@ -281,9 +236,7 @@ static void log_error_core(const char *file, int line, int level, const char *fmt, va_list args) { char errstr[MAX_STRING_LEN]; -#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED char scratch[MAX_STRING_LEN]; -#endif size_t len; int save_errno = errno; FILE *logf; @@ -348,14 +301,10 @@ static void log_error_core(const char *file, int line, int level, "(%d)%s: ", save_errno, strerror(save_errno)); } -#ifndef AP_UNSAFE_ERROR_LOG_UNESCAPED if (ap_vsnprintf(scratch, sizeof(scratch) - len, fmt, args)) { len += ap_escape_errorlog_item(errstr + len, scratch, sizeof(errstr) - len); } -#else - len += ap_vsnprintf(errstr + len, sizeof(errstr) - len, fmt, args); -#endif /* NULL if we are logging to syslog */ if (logf) { @@ -363,11 +312,9 @@ static void log_error_core(const char *file, int line, int level, fputc('\n', logf); fflush(logf); } -#ifdef HAVE_SYSLOG else { syslog(level & APLOG_LEVELMASK, "%s", errstr); } -#endif } API_EXPORT_NONSTD(void) ap_log_error(const char *file, int line, int level, @@ -488,8 +435,6 @@ API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) /* piped log support */ -#ifndef NO_PIPED_LOGS -#ifndef NO_RELIABLE_PIPED_LOGS /* forward declaration */ static void piped_log_maintenance(int reason, void *data, ap_wait_t status); @@ -500,7 +445,6 @@ static int piped_log_spawn(piped_log *pl) ap_block_alarms(); pid = fork(); if (pid == 0) { - /* XXX: this needs porting to OS2 and WIN32 */ /* XXX: need to check what open fds the logger is actually passed, * XXX: and CGIs for that matter ... cleanup_for_exec *should* * XXX: close all the relevant stuff, but hey, it could be broken. */ @@ -637,48 +581,3 @@ API_EXPORT(void) ap_close_piped_log(piped_log *pl) ap_kill_cleanup(pl->p, pl, piped_log_cleanup); ap_unblock_alarms(); } - -#else -static int piped_log_child(void *cmd, child_info *pinfo) -{ - /* Child process code for 'TransferLog "|..."'; - * may want a common framework for this, since I expect it will - * be common for other foo-loggers to want this sort of thing... - */ - int child_pid = 1; - - ap_cleanup_for_exec(); -#ifdef SIGHUP - signal(SIGHUP, SIG_IGN); -#endif - execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, (char *)NULL); - perror("exec"); - fprintf(stderr, "Exec of shell for logging failed!!!\n"); - return(child_pid); -} - - -API_EXPORT(piped_log *) ap_open_piped_log(pool *p, const char *program) -{ - piped_log *pl; - FILE *dummy; - if (!ap_spawn_child(p, piped_log_child, (void *)program, - kill_after_timeout, &dummy, NULL, NULL)) { - perror("ap_spawn_child"); - fprintf(stderr, "Couldn't fork child for piped log process\n"); - exit (1); - } - pl = ap_palloc(p, sizeof (*pl)); - pl->p = p; - pl->write_f = dummy; - - return pl; -} - - -API_EXPORT(void) ap_close_piped_log(piped_log *pl) -{ - ap_pfclose(pl->p, pl->write_f); -} -#endif -#endif diff --git a/usr.sbin/httpd/src/main/http_main.c b/usr.sbin/httpd/src/main/http_main.c index cd5ae9c5373..a97ed83c394 100644 --- a/usr.sbin/httpd/src/main/http_main.c +++ b/usr.sbin/httpd/src/main/http_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_main.c,v 1.37 2004/12/04 12:43:35 jmc Exp $ */ +/* $OpenBSD: http_main.c,v 1.38 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -81,15 +81,7 @@ * Extensive rework for Apache. */ -#ifndef SHARED_CORE_BOOTSTRAP -#ifndef SHARED_CORE_TIESTATIC - -#ifdef SHARED_CORE -#define REALMAIN ap_main -int ap_main(int argc, char *argv[]); -#else #define REALMAIN main -#endif #define CORE_PRIVATE @@ -108,60 +100,11 @@ int ap_main(int argc, char *argv[]); #include "scoreboard.h" #include "multithread.h" #include <sys/stat.h> -#ifdef USE_SHMGET_SCOREBOARD -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#endif -#ifdef SecureWare -#include <sys/security.h> -#include <sys/audit.h> -#include <prot.h> -#endif #include <netinet/tcp.h> -#ifdef HAVE_BSTRING_H -#include <bstring.h> /* for IRIX, FD_SET calls bzero() */ -#endif #ifdef MOD_SSL #include <openssl/evp.h> #endif -#ifdef MULTITHREAD -/* special debug stuff -- PCS */ - -/* Set this non-zero if you are prepared to put up with more than one log entry per second */ -#define SEVERELY_VERBOSE 0 - - /* APD1() to APD5() are macros to help us debug. They can either - * log to the screen or the error_log file. In release builds, these - * macros do nothing. In debug builds, they send messages at priority - * "debug" to the error log file, or if DEBUG_TO_CONSOLE is defined, - * to the console. - */ - -# ifdef _DEBUG -# ifndef DEBUG_TO_CONSOLE -# define APD1(a) ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,server_conf,a) -# define APD2(a,b) ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,server_conf,a,b) -# define APD3(a,b,c) ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,server_conf,a,b,c) -# define APD4(a,b,c,d) ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,server_conf,a,b,c,d) -# define APD5(a,b,c,d,e) ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO,server_conf,a,b,c,d,e) -# else -# define APD1(a) printf("%s\n",a) -# define APD2(a,b) do { printf(a,b);putchar('\n'); } while(0); -# define APD3(a,b,c) do { printf(a,b,c);putchar('\n'); } while(0); -# define APD4(a,b,c,d) do { printf(a,b,c,d);putchar('\n'); } while(0); -# define APD5(a,b,c,d,e) do { printf(a,b,c,d,e);putchar('\n'); } while(0); -# endif -# else /* !_DEBUG */ -# define APD1(a) -# define APD2(a,b) -# define APD3(a,b,c) -# define APD4(a,b,c,d) -# define APD5(a,b,c,d,e) -# endif /* _DEBUG */ -#endif /* MULTITHREAD */ - /* This next function is never used. It is here to ensure that if we * make all the modules into shared libraries that core httpd still * includes the full Apache API. Without this function the objects in @@ -181,11 +124,6 @@ API_EXPORT(void) ap_force_library_loading(void) { #define PATHSEPARATOR '/' - -#ifdef MINT -long _stksize = 32768; -#endif - DEF_Explain /* Defining GPROF when compiling uses the moncontrol() function to @@ -202,10 +140,8 @@ extern void moncontrol(int); #define MONCONTROL(x) #endif -#ifndef MULTITHREAD /* this just need to be anything non-NULL */ void *ap_dummy_mutex = &ap_dummy_mutex; -#endif /* * Actual definitions of config globals... here because this is @@ -218,9 +154,6 @@ int ap_docrootcheck=1; API_VAR_EXPORT uid_t ap_user_id=0; API_VAR_EXPORT char *ap_user_name=NULL; API_VAR_EXPORT gid_t ap_group_id=0; -#ifdef MULTIPLE_GROUPS -gid_t group_id_list[NGROUPS_MAX]; -#endif API_VAR_EXPORT int ap_max_requests_per_child=0; API_VAR_EXPORT int ap_threads_per_child=0; API_VAR_EXPORT int ap_excess_requests_per_child=0; @@ -247,20 +180,9 @@ struct accept_mutex_methods_s { typedef struct accept_mutex_methods_s accept_mutex_methods_s; accept_mutex_methods_s *amutex; -#ifdef SO_ACCEPTFILTER -int ap_acceptfilter = -#ifdef AP_ACCEPTFILTER_OFF - 0; -#else - 1; -#endif -#endif - int ap_dump_settings = 0; API_VAR_EXPORT int ap_extended_status = 0; -#ifdef EAPI API_VAR_EXPORT ap_ctx *ap_global_ctx; -#endif /* EAPI */ /* * The max child slot ever assigned, preserved across restarts. Necessary @@ -333,7 +255,6 @@ static int child_timeouts; int raise_sigstop_flags; #endif -#ifndef NO_OTHER_CHILD /* used to maintain list of children which aren't part of the scoreboard */ typedef struct other_child_rec other_child_rec; struct other_child_rec { @@ -344,7 +265,6 @@ struct other_child_rec { int write_fd; }; static other_child_rec *other_children; -#endif static pool *pglobal; /* Global pool */ static pool *pconf; /* Pool for config stuff */ @@ -355,9 +275,7 @@ static pool *pmutex; /* Pool for accept mutex in child */ static pool *pcommands; /* Pool for -C and -c switches */ static int APACHE_TLS my_pid; /* it seems silly to call getpid all the time */ -#ifndef MULTITHREAD static int my_child_num; -#endif scoreboard *ap_scoreboard_image = NULL; @@ -442,7 +360,6 @@ static void ap_set_version(void) } } -#ifdef EAPI API_EXPORT(void) ap_add_config_define(const char *define) { char **var; @@ -464,7 +381,6 @@ static void ap_call_close_connection_hook(conn_rec *c) (*m->close_connection)(c); return; } -#endif /* EAPI */ static APACHE_TLS int volatile exit_after_unblock = 0; @@ -537,270 +453,17 @@ static void clean_child_exit(int code) * uslock, pthread, sysvsem, fcntl, flock, os2sem, tpfcore and none. */ -#if defined(HAVE_FCNTL_SERIALIZED_ACCEPT) || defined(HAVE_FLOCK_SERIALIZED_ACCEPT) static void expand_lock_fname(pool *p) { /* XXXX possibly bogus cast */ ap_lock_fname = ap_psprintf(p, "%s.%lu", ap_server_root_relative(p, ap_lock_fname), (unsigned long)getpid()); } -#endif - -#if defined (HAVE_USLOCK_SERIALIZED_ACCEPT) -#include <ulocks.h> -static ulock_t uslock = NULL; - -#define accept_mutex_child_init_uslock(x) - -static void accept_mutex_init_uslock(pool *p) -{ - ptrdiff_t old; - usptr_t *us; - - - /* default is 8, allocate enough for all the children plus the parent */ - if ((old = usconfig(CONF_INITUSERS, HARD_SERVER_LIMIT + 1)) == -1) { - perror("usconfig(CONF_INITUSERS)"); - exit(-1); - } - - if ((old = usconfig(CONF_LOCKTYPE, US_NODEBUG)) == -1) { - perror("usconfig(CONF_LOCKTYPE)"); - exit(-1); - } - if ((old = usconfig(CONF_ARENATYPE, US_SHAREDONLY)) == -1) { - perror("usconfig(CONF_ARENATYPE)"); - exit(-1); - } - if ((us = usinit("/dev/zero")) == NULL) { - perror("usinit"); - exit(-1); - } - - if ((uslock = usnewlock(us)) == NULL) { - perror("usnewlock"); - exit(-1); - } -} - -static void accept_mutex_on_uslock(void) -{ - switch (ussetlock(uslock)) { - case 1: - /* got lock */ - break; - case 0: - fprintf(stderr, "didn't get lock\n"); - clean_child_exit(APEXIT_CHILDFATAL); - case -1: - perror("ussetlock"); - clean_child_exit(APEXIT_CHILDFATAL); - } -} - -static void accept_mutex_off_uslock(void) -{ - if (usunsetlock(uslock) == -1) { - perror("usunsetlock"); - clean_child_exit(APEXIT_CHILDFATAL); - } -} - -accept_mutex_methods_s accept_mutex_uslock_s = { - NULL, - accept_mutex_init_uslock, - accept_mutex_on_uslock, - accept_mutex_off_uslock, - "uslock" -}; -#endif - -#if defined (HAVE_PTHREAD_SERIALIZED_ACCEPT) - -/* This code probably only works on Solaris ... but it works really fast - * on Solaris. Note that pthread mutexes are *NOT* released when a task - * dies ... the task has to free it itself. So we block signals and - * try to be nice about releasing the mutex. - */ - -#include <pthread.h> - -static pthread_mutex_t *accept_mutex = (void *)(caddr_t) -1; -static int have_accept_mutex; -static sigset_t accept_block_mask; -static sigset_t accept_previous_mask; - -static void accept_mutex_child_cleanup_pthread(void *foo) -{ - if (accept_mutex != (void *)(caddr_t)-1 - && have_accept_mutex) { - pthread_mutex_unlock(accept_mutex); - } -} - -static void accept_mutex_child_init_pthread(pool *p) -{ - ap_register_cleanup(p, NULL, accept_mutex_child_cleanup_pthread, ap_null_cleanup); -} - -static void accept_mutex_cleanup_pthread(void *foo) -{ - if (accept_mutex != (void *)(caddr_t)-1 - && munmap((caddr_t) accept_mutex, sizeof(*accept_mutex))) { - perror("munmap"); - } - accept_mutex = (void *)(caddr_t)-1; -} - -/* remove_sync_sigs() is from APR 0.9.4 - * - * It is invalid to block synchronous signals, as such signals must - * be delivered on the thread that generated the original error - * (e.g., invalid storage reference). Blocking them interferes - * with proper recovery. - */ -static void remove_sync_sigs(sigset_t *sig_mask) -{ -#ifdef SIGABRT - sigdelset(sig_mask, SIGABRT); -#endif -#ifdef SIGBUS - sigdelset(sig_mask, SIGBUS); -#endif -#ifdef SIGEMT - sigdelset(sig_mask, SIGEMT); -#endif -#ifdef SIGFPE - sigdelset(sig_mask, SIGFPE); -#endif -#ifdef SIGILL - sigdelset(sig_mask, SIGILL); -#endif -#ifdef SIGIOT - sigdelset(sig_mask, SIGIOT); -#endif -#ifdef SIGPIPE - sigdelset(sig_mask, SIGPIPE); -#endif -#ifdef SIGSEGV - sigdelset(sig_mask, SIGSEGV); -#endif -#ifdef SIGSYS - sigdelset(sig_mask, SIGSYS); -#endif -#ifdef SIGTRAP - sigdelset(sig_mask, SIGTRAP); -#endif - -/* APR logic to remove SIGUSR2 not copied */ -} - -static void accept_mutex_init_pthread(pool *p) -{ - pthread_mutexattr_t mattr; - int fd; - - fd = open("/dev/zero", O_RDWR); - if (fd == -1) { - perror("open(/dev/zero)"); - exit(APEXIT_INIT); - } - accept_mutex = (pthread_mutex_t *) mmap((caddr_t) 0, sizeof(*accept_mutex), - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (accept_mutex == (void *) (caddr_t) - 1) { - perror("mmap /dev/zero"); - exit(APEXIT_INIT); - } - close(fd); - if ((errno = pthread_mutexattr_init(&mattr))) { - perror("pthread_mutexattr_init"); - exit(APEXIT_INIT); - } - if ((errno = pthread_mutexattr_setpshared(&mattr, - PTHREAD_PROCESS_SHARED))) { - perror("pthread_mutexattr_setpshared"); - exit(APEXIT_INIT); - } - if ((errno = pthread_mutex_init(accept_mutex, &mattr))) { - perror("pthread_mutex_init"); - exit(APEXIT_INIT); - } - sigfillset(&accept_block_mask); - sigdelset(&accept_block_mask, SIGHUP); - sigdelset(&accept_block_mask, SIGTERM); - sigdelset(&accept_block_mask, SIGUSR1); - remove_sync_sigs(&accept_block_mask); - ap_register_cleanup(p, NULL, accept_mutex_cleanup_pthread, ap_null_cleanup); -} - -static void accept_mutex_on_pthread(void) -{ - int err; - - if (sigprocmask(SIG_BLOCK, &accept_block_mask, &accept_previous_mask)) { - perror("sigprocmask(SIG_BLOCK)"); - clean_child_exit(APEXIT_CHILDFATAL); - } - /* We need to block alarms here, since if we get killed *right* after - * locking the mutex, have_accept_mutex will not be set, and our - * child cleanup will not work. - */ - ap_block_alarms(); - if ((err = pthread_mutex_lock(accept_mutex))) { - errno = err; - perror("pthread_mutex_lock"); - clean_child_exit(APEXIT_CHILDFATAL); - } - have_accept_mutex = 1; - ap_unblock_alarms(); -} - -static void accept_mutex_off_pthread(void) -{ - int err; - - /* Have to block alarms here, or else we might have a double-unlock, which - * is possible with pthread mutexes, since they are designed to be fast, - * and hence not necessarily make checks for ownership or multiple unlocks. - */ - ap_block_alarms(); - if ((err = pthread_mutex_unlock(accept_mutex))) { - errno = err; - perror("pthread_mutex_unlock"); - clean_child_exit(APEXIT_CHILDFATAL); - } - have_accept_mutex = 0; - ap_unblock_alarms(); - if (sigprocmask(SIG_SETMASK, &accept_previous_mask, NULL)) { - perror("sigprocmask(SIG_SETMASK)"); - clean_child_exit(1); - } -} - -accept_mutex_methods_s accept_mutex_pthread_s = { - accept_mutex_child_init_pthread, - accept_mutex_init_pthread, - accept_mutex_on_pthread, - accept_mutex_off_pthread, - "pthread" -}; -#endif - -#if defined (HAVE_SYSVSEM_SERIALIZED_ACCEPT) #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> -#ifdef NEED_UNION_SEMUN -union semun { - int val; - struct semid_ds *buf; - ushort *array; -}; - -#endif - static int sem_id = -1; static struct sembuf op_on; static struct sembuf op_off; @@ -889,87 +552,6 @@ accept_mutex_methods_s accept_mutex_sysvsem_s = { accept_mutex_off_sysvsem, "sysvsem" }; -#endif - -#if defined(HAVE_FCNTL_SERIALIZED_ACCEPT) -static struct flock lock_it; -static struct flock unlock_it; - -static int lock_fd = -1; - -#define accept_mutex_child_init_fcntl(x) - -/* - * Initialize mutex lock. - * Must be safe to call this on a restart. - */ -static void accept_mutex_init_fcntl(pool *p) -{ - - lock_it.l_whence = SEEK_SET; /* from current point */ - lock_it.l_start = 0; /* -"- */ - lock_it.l_len = 0; /* until end of file */ - lock_it.l_type = F_WRLCK; /* set exclusive/write lock */ - lock_it.l_pid = 0; /* pid not actually interesting */ - unlock_it.l_whence = SEEK_SET; /* from current point */ - unlock_it.l_start = 0; /* -"- */ - unlock_it.l_len = 0; /* until end of file */ - unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */ - unlock_it.l_pid = 0; /* pid not actually interesting */ - - expand_lock_fname(p); - lock_fd = ap_popenf_ex(p, ap_lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644, 1); - if (lock_fd == -1) { - perror("open"); - fprintf(stderr, "Cannot open lock file: %s\n", ap_lock_fname); - exit(APEXIT_INIT); - } - unlink(ap_lock_fname); -} - -static void accept_mutex_on_fcntl(void) -{ - int ret; - - while ((ret = fcntl(lock_fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR) { - /* nop */ - } - - if (ret < 0) { - ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, - "fcntl: F_SETLKW: Error getting accept lock, exiting! " - "Perhaps you need to use the LockFile directive to place " - "your lock file on a local disk!"); - clean_child_exit(APEXIT_CHILDFATAL); - } -} - -static void accept_mutex_off_fcntl(void) -{ - int ret; - - while ((ret = fcntl(lock_fd, F_SETLKW, &unlock_it)) < 0 && errno == EINTR) { - /* nop */ - } - if (ret < 0) { - ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, - "fcntl: F_SETLKW: Error freeing accept lock, exiting! " - "Perhaps you need to use the LockFile directive to place " - "your lock file on a local disk!"); - clean_child_exit(APEXIT_CHILDFATAL); - } -} - -accept_mutex_methods_s accept_mutex_fcntl_s = { - NULL, - accept_mutex_init_fcntl, - accept_mutex_on_fcntl, - accept_mutex_off_fcntl, - "fcntl" -}; -#endif - -#if defined(HAVE_FLOCK_SERIALIZED_ACCEPT) static int flock_fd = -1; @@ -1041,25 +623,6 @@ accept_mutex_methods_s accept_mutex_flock_s = { accept_mutex_off_flock, "flock" }; -#endif - -/* Generally, HAVE_NONE_SERIALIZED_ACCEPT simply won't work but - * for testing purposes, here it is... */ -#if defined HAVE_NONE_SERIALIZED_ACCEPT -#if !defined(MULTITHREAD) -/* Multithreaded systems don't complete between processes for - * the sockets. */ -#define NO_SERIALIZED_ACCEPT -#endif - -accept_mutex_methods_s accept_mutex_none_s = { - NULL, - NULL, - NULL, - NULL, - "none" -}; -#endif #define AP_FPTR1(x,y) { if (x) ((* x)(y)); } #define AP_FPTR0(x) { if (x) ((* x)()); } @@ -1072,52 +635,11 @@ accept_mutex_methods_s accept_mutex_none_s = { char *ap_default_mutex_method(void) { char *t; -#if defined USE_USLOCK_SERIALIZED_ACCEPT - t = "uslock"; -#elif defined USE_PTHREAD_SERIALIZED_ACCEPT - t = "pthread"; -#elif defined USE_SYSVSEM_SERIALIZED_ACCEPT t = "sysvsem"; -#elif defined USE_FCNTL_SERIALIZED_ACCEPT - t = "fcntl"; -#elif defined USE_FLOCK_SERIALIZED_ACCEPT - t = "flock"; -#elif defined USE_OS2SEM_SERIALIZED_ACCEPT - t = "os2sem"; -#elif defined USE_TPF_CORE_SERIALIZED_ACCEPT - t = "tpfcore"; -#elif defined USE_BEOS_SERIALIZED_ACCEPT - t = "beos_sem"; -#elif defined USE_NONE_SERIALIZED_ACCEPT - t = "none"; -#else - t = "default"; -#endif -#if defined HAVE_USLOCK_SERIALIZED_ACCEPT - if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"uslock")))) - return "uslock"; -#endif -#if defined HAVE_PTHREAD_SERIALIZED_ACCEPT - if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"pthread")))) - return "pthread"; -#endif -#if defined HAVE_SYSVSEM_SERIALIZED_ACCEPT if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"sysvsem")))) return "sysvsem"; -#endif -#if defined HAVE_FCNTL_SERIALIZED_ACCEPT - if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"fcntl")))) - return "fcntl"; -#endif -#if defined HAVE_FLOCK_SERIALIZED_ACCEPT if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"flock")))) return "flock"; -#endif -#if defined HAVE_NONE_SERIALIZED_ACCEPT - if ((!(strcasecmp(t,"default"))) || (!(strcasecmp(t,"none")))) - return "none"; -#endif - fprintf(stderr, "No default accept serialization known!!\n"); exit(APEXIT_INIT); /*NOTREACHED */ @@ -1129,36 +651,12 @@ char *ap_init_mutex_method(char *t) if (!(strcasecmp(t,"default"))) t = ap_default_mutex_method(); -#if defined HAVE_USLOCK_SERIALIZED_ACCEPT - if (!(strcasecmp(t,"uslock"))) { - amutex = &accept_mutex_uslock_s; - } else -#endif -#if defined HAVE_PTHREAD_SERIALIZED_ACCEPT - if (!(strcasecmp(t,"pthread"))) { - amutex = &accept_mutex_pthread_s; - } else -#endif -#if defined HAVE_SYSVSEM_SERIALIZED_ACCEPT if (!(strcasecmp(t,"sysvsem"))) { amutex = &accept_mutex_sysvsem_s; } else -#endif -#if defined HAVE_FCNTL_SERIALIZED_ACCEPT - if (!(strcasecmp(t,"fcntl"))) { - amutex = &accept_mutex_fcntl_s; - } else -#endif -#if defined HAVE_FLOCK_SERIALIZED_ACCEPT if (!(strcasecmp(t,"flock"))) { amutex = &accept_mutex_flock_s; } else -#endif -#if defined HAVE_NONE_SERIALIZED_ACCEPT - if (!(strcasecmp(t,"none"))) { - amutex = &accept_mutex_none_s; - } else -#endif { /* Ignore this directive on Windows */ if (server_conf) { @@ -1178,11 +676,7 @@ char *ap_init_mutex_method(char *t) * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT * when it's safe in the single Listen case. */ -#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT #define SAFE_ACCEPT(stmt) do {if(ap_listeners->next != ap_listeners) {stmt;}} while(0) -#else -#define SAFE_ACCEPT(stmt) do {stmt;} while(0) -#endif static void usage(char *bin) { @@ -1193,11 +687,7 @@ static void usage(char *bin) pad[i] = ' '; pad[i] = '\0'; fprintf(stderr, "Usage: %s [-FhLlSTtuVvX] [-C directive] [-c directive] [-D parameter]\n", bin); -#ifdef SHARED_CORE - fprintf(stderr, " %s [-d serverroot] [-f config] [-R libexecdir]\n", pad); -#else fprintf(stderr, " %s [-d serverroot] [-f config]\n", pad); -#endif fprintf(stderr, "Options:\n"); fprintf(stderr, " -C directive : process directive before reading config files\n"); fprintf(stderr, " -c directive : process directive after reading config files\n"); @@ -1208,9 +698,6 @@ static void usage(char *bin) fprintf(stderr, " -h : list available command line options (this page)\n"); fprintf(stderr, " -L : list available configuration directives\n"); fprintf(stderr, " -l : list compiled-in modules\n"); -#ifdef SHARED_CORE - fprintf(stderr, " -R libexecdir : specify an alternate location for shared object files\n"); -#endif fprintf(stderr, " -S : show parsed settings (currently only vhost settings)\n"); fprintf(stderr, " -T : run syntax check for config files (without docroot check)\n"); fprintf(stderr, " -t : run syntax check for config files (with docroot check)\n"); @@ -1291,9 +778,7 @@ static void timeout(int sig) ap_log_transaction(log_req); } -#ifdef EAPI ap_call_close_connection_hook(save_req->connection); -#endif /* EAPI */ ap_bsetflag(save_req->connection->client, B_EOUT, 1); ap_bclose(save_req->connection->client); @@ -1303,9 +788,7 @@ static void timeout(int sig) ap_longjmp(jmpbuffer, 1); } else { /* abort the connection */ -#ifdef EAPI ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ ap_bsetflag(current_conn->client, B_EOUT, 1); ap_bclose(current_conn->client); current_conn->aborted = 1; @@ -1365,9 +848,6 @@ API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x) "ap_set_callback_and_alarm: possible nested timer!"); } alarm_fn = fn; -#ifndef OPTIMIZE_TIMEOUTS - old = alarm(x); -#else if (child_timeouts) { old = alarm(x); } @@ -1380,7 +860,6 @@ API_EXPORT(unsigned int) ap_set_callback_and_alarm(void (*fn) (int), int x) ap_scoreboard_image->servers[my_child_num].timeout_len = x; ++ap_scoreboard_image->servers[my_child_num].cur_vtime; } -#endif return (old); } @@ -1453,36 +932,13 @@ API_EXPORT(void) ap_kill_timeout(request_rec *dummy) * we have created a home-brew lingering_close. * * Many operating systems tend to block, puke, or otherwise mishandle - * calls to shutdown only half of the connection. You should define - * NO_LINGCLOSE in ap_config.h if such is the case for your system. + * calls to shutdown only half of the connection. */ #ifndef MAX_SECS_TO_LINGER #define MAX_SECS_TO_LINGER 30 #endif -#ifdef USE_SO_LINGER -#define NO_LINGCLOSE /* The two lingering options are exclusive */ - -static void sock_enable_linger(int s) -{ - struct linger li; - - li.l_onoff = 1; - li.l_linger = MAX_SECS_TO_LINGER; - - if (setsockopt(s, SOL_SOCKET, SO_LINGER, - (char *) &li, sizeof(struct linger)) < 0) { - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, - "setsockopt: (SO_LINGER)"); - /* not a fatal error */ - } -} - -#else #define sock_enable_linger(s) /* NOOP */ -#endif /* USE_SO_LINGER */ - -#ifndef NO_LINGCLOSE /* Special version of timeout for lingering_close */ @@ -1527,16 +983,12 @@ static void lingering_close(request_rec *r) /* Send any leftover data to the client, but never try to again */ if (ap_bflush(r->connection->client) == -1) { -#ifdef EAPI ap_call_close_connection_hook(r->connection); -#endif /* EAPI */ ap_kill_timeout(r); ap_bclose(r->connection->client); return; } -#ifdef EAPI ap_call_close_connection_hook(r->connection); -#endif /* EAPI */ ap_bsetflag(r->connection->client, B_EOUT, 1); /* Close our half of the connection --- send the client a FIN */ @@ -1585,13 +1037,11 @@ static void lingering_close(request_rec *r) ap_kill_timeout(r); } -#endif /* ndef NO_LINGCLOSE */ /***************************************************************** * dealing with other children */ -#ifndef NO_OTHER_CHILD API_EXPORT(void) ap_register_other_child(int pid, void (*maintenance) (int reason, void *, ap_wait_t status), void *data, int write_fd) @@ -1693,7 +1143,6 @@ static int reap_other_child(int pid, ap_wait_t status) } return -1; } -#endif /***************************************************************** * @@ -1704,167 +1153,18 @@ static int reap_other_child(int pid, ap_wait_t status) * We begin with routines which deal with the file itself... */ -#ifdef MULTITHREAD -/* - * In the multithreaded mode, have multiple threads - not multiple - * processes that need to talk to each other. Just use a simple - * malloc. But let the routines that follow, think that you have - * shared memory (so they use memcpy etc.) - */ - -static void reinit_scoreboard(pool *p) -{ - ap_assert(!ap_scoreboard_image); - ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE); - if (ap_scoreboard_image == NULL) { - fprintf(stderr, "Ouch! Out of memory reiniting scoreboard!\n"); - } - memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE); -} - -void cleanup_scoreboard(void) -{ - ap_assert(ap_scoreboard_image); - free(ap_scoreboard_image); - ap_scoreboard_image = NULL; -} - -API_EXPORT(void) ap_sync_scoreboard_image(void) -{ -} - - -#else /* MULTITHREAD */ -#if defined(USE_POSIX_SCOREBOARD) -#include <sys/mman.h> -/* - * POSIX 1003.4 style - * - * Note 1: - * As of version 4.23A, shared memory in QNX must reside under /dev/shmem, - * where no subdirectories allowed. - * - * POSIX shm_open() and shm_unlink() will take care about this issue, - * but to avoid confusion, I suggest to redefine scoreboard file name - * in httpd.conf to cut "logs/" from it. With default setup actual name - * will be "/dev/shmem/logs.apache_status". - * - * If something went wrong and Apache did not unlinked this object upon - * exit, you can remove it manually, using "rm -f" command. - * - * Note 2: - * <sys/mman.h> in QNX defines MAP_ANON, but current implementation - * does NOT support BSD style anonymous mapping. So, the order of - * conditional compilation is important: - * this #ifdef section must be ABOVE the next one (BSD style). - * - * I tested this stuff and it works fine for me, but if it provides - * trouble for you, just comment out USE_MMAP_SCOREBOARD in QNX section - * of ap_config.h - * - * June 5, 1997, - * Igor N. Kovalenko -- infoh@mail.wplus.net - */ - -static void cleanup_shared_mem(void *d) -{ - shm_unlink(ap_scoreboard_fname); -} - -static void setup_shared_mem(pool *p) -{ - char buf[512]; - caddr_t m; - int fd; - - fd = shm_open(ap_scoreboard_fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); - if (fd == -1) { - ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); - exit(APEXIT_INIT); - } - if (ltrunc(fd, (off_t) SCOREBOARD_SIZE, SEEK_SET) == -1) { - ap_snprintf(buf, sizeof(buf), "%s: could not ltrunc scoreboard", - ap_server_argv0); - perror(buf); - shm_unlink(ap_scoreboard_fname); - exit(APEXIT_INIT); - } - if ((m = (caddr_t) mmap((caddr_t) 0, - (size_t) SCOREBOARD_SIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, (off_t) 0)) == (caddr_t) - 1) { - ap_snprintf(buf, sizeof(buf), "%s: cannot mmap scoreboard", - ap_server_argv0); - perror(buf); - shm_unlink(ap_scoreboard_fname); - exit(APEXIT_INIT); - } - close(fd); - ap_register_cleanup(p, NULL, cleanup_shared_mem, ap_null_cleanup); - ap_scoreboard_image = (scoreboard *) m; - ap_scoreboard_image->global.running_generation = 0; -} - -static void reopen_scoreboard(pool *p) -{ -} - -#elif defined(USE_MMAP_SCOREBOARD) - static void setup_shared_mem(pool *p) { caddr_t m; -#if defined(MAP_ANON) /* BSD style */ -#if defined(MAP_TMPFILE) - { - char mfile[] = "/tmp/apache_shmem_XXXX"; - int fd = mkstemp(mfile); - if (fd == -1) { - perror("open"); - fprintf(stderr, "%s: Could not open %s\n", ap_server_argv0, mfile); - exit(APEXIT_INIT); - } - m = mmap((caddr_t) 0, SCOREBOARD_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (m == (caddr_t) - 1) { - perror("mmap"); - fprintf(stderr, "%s: Could not mmap %s\n", ap_server_argv0, mfile); - exit(APEXIT_INIT); - } - close(fd); - unlink(mfile); - } -#else m = mmap((caddr_t) 0, SCOREBOARD_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); -#endif if (m == (caddr_t) - 1) { perror("mmap"); fprintf(stderr, "%s: Could not mmap memory\n", ap_server_argv0); exit(APEXIT_INIT); } -#else -/* Sun style */ - int fd; - - fd = open("/dev/zero", O_RDWR); - if (fd == -1) { - perror("open"); - fprintf(stderr, "%s: Could not open /dev/zero\n", ap_server_argv0); - exit(APEXIT_INIT); - } - m = mmap((caddr_t) 0, SCOREBOARD_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (m == (caddr_t) - 1) { - perror("mmap"); - fprintf(stderr, "%s: Could not mmap /dev/zero\n", ap_server_argv0); - exit(APEXIT_INIT); - } - close(fd); -#endif ap_scoreboard_image = (scoreboard *) m; ap_scoreboard_image->global.running_generation = 0; } @@ -1873,149 +1173,6 @@ static void reopen_scoreboard(pool *p) { } -#elif defined(USE_SHMGET_SCOREBOARD) -static key_t shmkey = IPC_PRIVATE; -static int shmid = -1; - -static void setup_shared_mem(pool *p) -{ - struct shmid_ds shmbuf; -#ifdef MOVEBREAK - char *obrk; -#endif - - if ((shmid = shmget(shmkey, SCOREBOARD_SIZE, IPC_CREAT | SHM_R | SHM_W)) == -1) { - ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, - "could not call shmget"); - exit(APEXIT_INIT); - } - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, - "created shared memory segment #%d", shmid); - -#ifdef MOVEBREAK - /* - * Some SysV systems place the shared segment WAY too close - * to the dynamic memory break point (sbrk(0)). This severely - * limits the use of malloc/sbrk in the program since sbrk will - * refuse to move past that point. - * - * To get around this, we move the break point "way up there", - * attach the segment and then move break back down. Ugly - */ - if ((obrk = sbrk(MOVEBREAK)) == (char *) -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "sbrk() could not move break"); - } -#endif - -#define BADSHMAT ((scoreboard *)(-1)) - if ((ap_scoreboard_image = (scoreboard *) shmat(shmid, 0, 0)) == BADSHMAT) { - ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, "shmat error"); - /* - * We exit below, after we try to remove the segment - */ - } - /* only worry about permissions if we attached the segment - and we want/need to change the uid/gid */ - else if (ap_change_shmem_uid) { - if (shmctl(shmid, IPC_STAT, &shmbuf) != 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "shmctl() could not stat segment #%d", shmid); - } - else { - shmbuf.shm_perm.uid = ap_user_id; - shmbuf.shm_perm.gid = ap_group_id; - if (shmctl(shmid, IPC_SET, &shmbuf) != 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "shmctl() could not set segment #%d", shmid); - } - } - } - /* - * We must avoid leaving segments in the kernel's - * (small) tables. - */ - if (shmctl(shmid, IPC_RMID, NULL) != 0) { - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, - "shmctl: IPC_RMID: could not remove shared memory segment #%d", - shmid); - } - if (ap_scoreboard_image == BADSHMAT) /* now bailout */ - exit(APEXIT_INIT); - -#ifdef MOVEBREAK - if (obrk == (char *) -1) - return; /* nothing else to do */ - if (sbrk(-(MOVEBREAK)) == (char *) -1) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "sbrk() could not move break back"); - } -#endif - ap_scoreboard_image->global.running_generation = 0; -} - -static void reopen_scoreboard(pool *p) -{ -} - -#else -#define SCOREBOARD_FILE -static scoreboard _scoreboard_image; -static int scoreboard_fd = -1; - -/* XXX: things are seriously screwed if we ever have to do a partial - * read or write ... we could get a corrupted scoreboard - */ -static int force_write(int fd, void *buffer, int bufsz) -{ - int rv, orig_sz = bufsz; - - do { - rv = write(fd, buffer, bufsz); - if (rv > 0) { - buffer = (char *) buffer + rv; - bufsz -= rv; - } - } while ((rv > 0 && bufsz > 0) || (rv == -1 && errno == EINTR)); - - return rv < 0 ? rv : orig_sz - bufsz; -} - -static int force_read(int fd, void *buffer, int bufsz) -{ - int rv, orig_sz = bufsz; - - do { - rv = read(fd, buffer, bufsz); - if (rv > 0) { - buffer = (char *) buffer + rv; - bufsz -= rv; - } - } while ((rv > 0 && bufsz > 0) || (rv == -1 && errno == EINTR)); - - return rv < 0 ? rv : orig_sz - bufsz; -} - -static void cleanup_scoreboard_file(void *foo) -{ - unlink(ap_scoreboard_fname); -} - -void reopen_scoreboard(pool *p) -{ - if (scoreboard_fd != -1) - ap_pclosef(p, scoreboard_fd); - - scoreboard_fd = ap_popenf_ex(p, ap_scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0666, 1); - if (scoreboard_fd == -1) { - perror(ap_scoreboard_fname); - fprintf(stderr, "Cannot open scoreboard file:\n"); - clean_child_exit(1); - } -} -#endif - /* Called by parent process */ static void reinit_scoreboard(pool *p) { @@ -2023,28 +1180,11 @@ static void reinit_scoreboard(pool *p) if (ap_scoreboard_image) running_gen = ap_scoreboard_image->global.running_generation; -#ifndef SCOREBOARD_FILE if (ap_scoreboard_image == NULL) { setup_shared_mem(p); } memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE); ap_scoreboard_image->global.running_generation = running_gen; -#else - ap_scoreboard_image = &_scoreboard_image; - ap_scoreboard_fname = ap_server_root_relative(p, ap_scoreboard_fname); - - scoreboard_fd = ap_popenf_ex(p, ap_scoreboard_fname, O_CREAT | O_BINARY | O_RDWR, 0644, 1); - if (scoreboard_fd == -1) { - perror(ap_scoreboard_fname); - fprintf(stderr, "Cannot open scoreboard file:\n"); - exit(APEXIT_INIT); - } - ap_register_cleanup(p, NULL, cleanup_scoreboard_file, ap_null_cleanup); - - memset((char *) ap_scoreboard_image, 0, sizeof(*ap_scoreboard_image)); - ap_scoreboard_image->global.running_generation = running_gen; - force_write(scoreboard_fd, ap_scoreboard_image, sizeof(*ap_scoreboard_image)); -#endif } /* Routines called to deal with the scoreboard image @@ -2060,14 +1200,8 @@ static void reinit_scoreboard(pool *p) ap_inline void ap_sync_scoreboard_image(void) { -#ifdef SCOREBOARD_FILE - lseek(scoreboard_fd, 0L, 0); - force_read(scoreboard_fd, ap_scoreboard_image, sizeof(*ap_scoreboard_image)); -#endif } -#endif /* MULTITHREAD */ - API_EXPORT(int) ap_exists_scoreboard_image(void) { return (ap_scoreboard_image ? 1 : 0); @@ -2076,10 +1210,6 @@ API_EXPORT(int) ap_exists_scoreboard_image(void) static ap_inline void put_scoreboard_info(int child_num, short_score *new_score_rec) { -#ifdef SCOREBOARD_FILE - lseek(scoreboard_fd, (long) child_num * sizeof(short_score), 0); - force_write(scoreboard_fd, new_score_rec, sizeof(short_score)); -#endif } /* a clean exit from the parent with proper cleanup */ @@ -2088,9 +1218,7 @@ static void clean_parent_exit(int code) { /* Clear the pool - including any registered cleanups */ ap_destroy_pool(pglobal); -#ifdef EAPI ap_kill_alloc_shared(); -#endif fdcache_closeall(); exit(code); } @@ -2110,14 +1238,9 @@ API_EXPORT(int) ap_update_child_status(int child_num, int status, request_rec *r old_status = ss->status; ss->status = status; -#ifdef OPTIMIZE_TIMEOUTS ++ss->cur_vtime; -#endif if (ap_extended_status) { -#ifndef OPTIMIZE_TIMEOUTS - ss->last_used = time(NULL); -#endif if (status == SERVER_READY || status == SERVER_DEAD) { /* * Reset individual counters @@ -2158,11 +1281,6 @@ API_EXPORT(int) ap_update_child_status(int child_num, int status, request_rec *r */ ss->vhostrec = NULL; ap_scoreboard_image->parent[child_num].generation = ap_my_generation; -#ifdef SCOREBOARD_FILE - lseek(scoreboard_fd, XtOffsetOf(scoreboard, parent[child_num]), 0); - force_write(scoreboard_fd, &ap_scoreboard_image->parent[child_num], - sizeof(parent_score)); -#endif } put_scoreboard_info(child_num, ss); @@ -2171,20 +1289,11 @@ API_EXPORT(int) ap_update_child_status(int child_num, int status, request_rec *r static void update_scoreboard_global(void) { -#ifdef SCOREBOARD_FILE - lseek(scoreboard_fd, - (char *) &ap_scoreboard_image->global -(char *) ap_scoreboard_image, 0); - force_write(scoreboard_fd, &ap_scoreboard_image->global, - sizeof ap_scoreboard_image->global); -#endif } void ap_time_process_request(int child_num, int status) { short_score *ss; -#if defined(NO_GETTIMEOFDAY) && !defined(NO_TIMES) - struct tms tms_blk; -#endif if (child_num < 0) return; @@ -2193,30 +1302,16 @@ void ap_time_process_request(int child_num, int status) ss = &ap_scoreboard_image->servers[child_num]; if (status == START_PREQUEST) { -#if defined(NO_GETTIMEOFDAY) -#ifndef NO_TIMES - if ((ss->start_time = times(&tms_blk)) == -1) -#endif /* NO_TIMES */ - ss->start_time = (clock_t) 0; -#else if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0) ss->start_time.tv_sec = ss->start_time.tv_usec = 0L; -#endif } else if (status == STOP_PREQUEST) { -#if defined(NO_GETTIMEOFDAY) -#ifndef NO_TIMES - if ((ss->stop_time = times(&tms_blk)) == -1) -#endif - ss->stop_time = ss->start_time = (clock_t) 0; -#else if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0) ss->stop_time.tv_sec = ss->stop_time.tv_usec = ss->start_time.tv_sec = ss->start_time.tv_usec = 0L; -#endif } @@ -2234,9 +1329,7 @@ static void increment_counts(int child_num, request_rec *r) if (r->sent_bodyct) ap_bgetopt(r->connection->client, BO_BYTECT, &bs); -#ifndef NO_TIMES times(&ss->times); -#endif ss->access_count++; ss->my_access_count++; ss->conn_count++; @@ -2260,16 +1353,13 @@ static int find_child_by_pid(int pid) static void reclaim_child_processes(int terminate) { -#ifndef MULTITHREAD int i, status; long int waittime = 1024 * 16; /* in usecs */ struct timeval tv; int waitret, tries; int not_dead_yet; int ret; -#ifndef NO_OTHER_CHILD other_child_rec *ocr, *nocr; -#endif ap_sync_scoreboard_image(); @@ -2349,7 +1439,6 @@ static void reclaim_child_processes(int terminate) break; } } -#ifndef NO_OTHER_CHILD for (ocr = other_children; ocr; ocr = nocr) { nocr = ocr->next; if (ocr->pid == -1) @@ -2370,39 +1459,14 @@ static void reclaim_child_processes(int terminate) (*ocr->maintenance) (OC_REASON_LOST, ocr->data, (ap_wait_t)-1); } } -#endif if (!not_dead_yet) { /* nothing left to wait for */ break; } } -#endif /* ndef MULTITHREAD */ } -#if defined(NEED_WAITPID) -/* - Systems without a real waitpid sometimes lose a child's exit while waiting - for another. Search through the scoreboard for missing children. - */ -int reap_children(ap_wait_t *status) -{ - int n, pid; - - for (n = 0; n < max_daemons_limit; ++n) { - ap_sync_scoreboard_image(); - if (ap_scoreboard_image->servers[n].status != SERVER_DEAD && - kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) { - ap_update_child_status(n, SERVER_DEAD, NULL); - /* just mark it as having a successful exit status */ - bzero((char *) status, sizeof(ap_wait_t)); - return(pid); - } - } - return 0; -} -#endif - /* Finally, this routine is used by the caretaker process to wait for * a while... */ @@ -2421,9 +1485,7 @@ static int wait_or_timeout(ap_wait_t *status) ++wait_or_timeout_counter; if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { wait_or_timeout_counter = 0; -#ifndef NO_OTHER_CHILD probe_writable_fds(); -#endif } ret = waitpid(-1, status, WNOHANG); if (ret == -1 && errno == EINTR) { @@ -2432,11 +1494,6 @@ static int wait_or_timeout(ap_wait_t *status) if (ret > 0) { return ret; } -#ifdef NEED_WAITPID - if ((ret = reap_children(status)) > 0) { - return ret; - } -#endif tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000; tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000; ap_select(0, NULL, NULL, NULL, &tv); @@ -2453,9 +1510,6 @@ static int wait_or_timeout(ap_wait_t *status) #define NumSIG 32 /* for 1998's unixes, this is still a good assumption */ #endif -#ifdef SYS_SIGLIST /* platform has sys_siglist[] */ -#define INIT_SIGLIST() /*nothing*/ -#else /* platform has no sys_siglist[], define our own */ #define SYS_SIGLIST ap_sys_siglist #define INIT_SIGLIST() siglist_init(); @@ -2466,114 +1520,41 @@ static void siglist_init(void) int sig; ap_sys_siglist[0] = "Signal 0"; -#ifdef SIGHUP ap_sys_siglist[SIGHUP] = "Hangup"; -#endif -#ifdef SIGINT ap_sys_siglist[SIGINT] = "Interrupt"; -#endif -#ifdef SIGQUIT ap_sys_siglist[SIGQUIT] = "Quit"; -#endif -#ifdef SIGILL ap_sys_siglist[SIGILL] = "Illegal instruction"; -#endif -#ifdef SIGTRAP ap_sys_siglist[SIGTRAP] = "Trace/BPT trap"; -#endif -#ifdef SIGIOT ap_sys_siglist[SIGIOT] = "IOT instruction"; -#endif -#ifdef SIGABRT ap_sys_siglist[SIGABRT] = "Abort"; -#endif -#ifdef SIGEMT ap_sys_siglist[SIGEMT] = "Emulator trap"; -#endif -#ifdef SIGFPE ap_sys_siglist[SIGFPE] = "Arithmetic exception"; -#endif -#ifdef SIGKILL ap_sys_siglist[SIGKILL] = "Killed"; -#endif -#ifdef SIGBUS ap_sys_siglist[SIGBUS] = "Bus error"; -#endif -#ifdef SIGSEGV ap_sys_siglist[SIGSEGV] = "Segmentation fault"; -#endif -#ifdef SIGSYS ap_sys_siglist[SIGSYS] = "Bad system call"; -#endif -#ifdef SIGPIPE ap_sys_siglist[SIGPIPE] = "Broken pipe"; -#endif -#ifdef SIGALRM ap_sys_siglist[SIGALRM] = "Alarm clock"; -#endif -#ifdef SIGTERM ap_sys_siglist[SIGTERM] = "Terminated"; -#endif -#ifdef SIGUSR1 ap_sys_siglist[SIGUSR1] = "User defined signal 1"; -#endif -#ifdef SIGUSR2 ap_sys_siglist[SIGUSR2] = "User defined signal 2"; -#endif -#ifdef SIGCLD - ap_sys_siglist[SIGCLD] = "Child status change"; -#endif -#ifdef SIGCHLD ap_sys_siglist[SIGCHLD] = "Child status change"; -#endif -#ifdef SIGPWR - ap_sys_siglist[SIGPWR] = "Power-fail restart"; -#endif -#ifdef SIGWINCH ap_sys_siglist[SIGWINCH] = "Window changed"; -#endif -#ifdef SIGURG ap_sys_siglist[SIGURG] = "urgent socket condition"; -#endif -#ifdef SIGPOLL - ap_sys_siglist[SIGPOLL] = "Pollable event occurred"; -#endif -#ifdef SIGIO ap_sys_siglist[SIGIO] = "socket I/O possible"; -#endif -#ifdef SIGSTOP ap_sys_siglist[SIGSTOP] = "Stopped (signal)"; -#endif -#ifdef SIGTSTP ap_sys_siglist[SIGTSTP] = "Stopped"; -#endif -#ifdef SIGCONT ap_sys_siglist[SIGCONT] = "Continued"; -#endif -#ifdef SIGTTIN ap_sys_siglist[SIGTTIN] = "Stopped (tty input)"; -#endif -#ifdef SIGTTOU ap_sys_siglist[SIGTTOU] = "Stopped (tty output)"; -#endif -#ifdef SIGVTALRM ap_sys_siglist[SIGVTALRM] = "virtual timer expired"; -#endif -#ifdef SIGPROF ap_sys_siglist[SIGPROF] = "profiling timer expired"; -#endif -#ifdef SIGXCPU ap_sys_siglist[SIGXCPU] = "exceeded cpu limit"; -#endif -#ifdef SIGXFSZ ap_sys_siglist[SIGXFSZ] = "exceeded file size limit"; -#endif for (sig=0; sig < sizeof(ap_sys_siglist)/sizeof(ap_sys_siglist[0]); ++sig) if (ap_sys_siglist[sig] == NULL) ap_sys_siglist[sig] = ""; } -#endif /* platform has sys_siglist[] */ - /* handle all varieties of core dumping signals */ static void sig_coredump(int sig) @@ -2670,7 +1651,6 @@ static void restart(int sig) static void set_signals(void) { -#ifndef NO_USE_SIGACTION struct sigaction sa; sigemptyset(&sa.sa_mask); @@ -2678,55 +1658,29 @@ static void set_signals(void) if (!one_process) { sa.sa_handler = sig_coredump; -#if defined(SA_ONESHOT) - sa.sa_flags = SA_ONESHOT; -#elif defined(SA_RESETHAND) sa.sa_flags = SA_RESETHAND; -#endif -#ifdef SIGSEGV_CHECK - if (sigaction(SIGSEGV, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGSEGV)"); -#endif /* SIGSEGV_CHECK */ -#ifdef SIGBUS if (sigaction(SIGBUS, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGBUS)"); -#endif -#ifdef SIGABORT - if (sigaction(SIGABORT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGABORT)"); -#endif -#ifdef SIGABRT if (sigaction(SIGABRT, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGABRT)"); -#endif -#ifdef SIGILL if (sigaction(SIGILL, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGILL)"); -#endif sa.sa_flags = 0; } sa.sa_handler = sig_term; if (sigaction(SIGTERM, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGTERM)"); -#ifdef SIGINT if (sigaction(SIGINT, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGINT)"); -#endif -#ifdef SIGXCPU sa.sa_handler = SIG_DFL; if (sigaction(SIGXCPU, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGXCPU)"); -#endif -#ifdef SIGXFSZ sa.sa_handler = SIG_DFL; if (sigaction(SIGXFSZ, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGXFSZ)"); -#endif -#ifdef SIGPIPE sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGPIPE)"); -#endif /* we want to ignore HUPs and USR1 while we're busy processing one */ sigaddset(&sa.sa_mask, SIGHUP); @@ -2736,42 +1690,6 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGHUP)"); if (sigaction(SIGUSR1, &sa, NULL) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "sigaction(SIGUSR1)"); -#else - if (!one_process) { -#ifdef SIGSEGV_CHECK - signal(SIGSEGV, sig_coredump); -#endif /* SIGSEGV_CHECK */ -#ifdef SIGBUS - signal(SIGBUS, sig_coredump); -#endif /* SIGBUS */ -#ifdef SIGABORT - signal(SIGABORT, sig_coredump); -#endif /* SIGABORT */ -#ifdef SIGABRT - signal(SIGABRT, sig_coredump); -#endif /* SIGABRT */ -#ifdef SIGILL - signal(SIGILL, sig_coredump); -#endif /* SIGILL */ -#ifdef SIGXCPU - signal(SIGXCPU, SIG_DFL); -#endif /* SIGXCPU */ -#ifdef SIGXFSZ - signal(SIGXFSZ, SIG_DFL); -#endif /* SIGXFSZ */ - } - signal(SIGTERM, sig_term); -#ifdef SIGHUP - signal(SIGHUP, restart); -#endif /* SIGHUP */ -#ifdef SIGUSR1 - signal(SIGUSR1, restart); -#endif /* SIGUSR1 */ -#ifdef SIGPIPE - signal(SIGPIPE, SIG_IGN); -#endif /* SIGPIPE */ - -#endif } @@ -2794,7 +1712,6 @@ static void detach(void) } RAISE_SIGSTOP(DETACH); } -#ifndef NO_SETSID if ((pgrp = setsid()) == -1) { perror("setsid"); fprintf(stderr, "%s: setsid failed\n", ap_server_argv0); @@ -2803,13 +1720,6 @@ static void detach(void) "running under a process management tool like daemontools\n"); exit(1); } -#else - if ((pgrp = setpgrp(getpid(), 0)) == -1) { - perror("setpgrp"); - fprintf(stderr, "%s: setpgrp failed\n", ap_server_argv0); - exit(1); - } -#endif /* close out the standard file descriptors */ if (freopen("/dev/null", "r", stdin) == NULL) { @@ -2862,8 +1772,6 @@ static void set_group_privs(void) else name = ap_user_name; - /* OS/2 and TPF don't support groups. */ - /* * Set the GID before initgroups(), since on some platforms * setgid() is known to zap the group list. @@ -2883,13 +1791,6 @@ static void set_group_privs(void) "and Group %u", name, (unsigned)ap_group_id); clean_child_exit(APEXIT_CHILDFATAL); } -#ifdef MULTIPLE_GROUPS - if (getgroups(NGROUPS_MAX, group_id_list) == -1) { - ap_log_error(APLOG_MARK, APLOG_ALERT, server_conf, - "getgroups: unable to get group list"); - clean_child_exit(APEXIT_CHILDFATAL); - } -#endif /* MULTIPLE_GROUPS */ } } @@ -2939,11 +1840,8 @@ static conn_rec *new_connection(pool *p, server_rec *server, BUFF *inout, conn->remote_addr = *remaddr; conn->remote_ip = ap_pstrdup(conn->pool, inet_ntoa(conn->remote_addr.sin_addr)); -#ifdef EAPI conn->ctx = ap_ctx_new(conn->pool); -#endif /* EAPI */ -#ifdef EAPI /* * Invoke the `new_connection' hook of modules to let them do * some connection dependent actions before we go on with @@ -2956,12 +1854,10 @@ static conn_rec *new_connection(pool *p, server_rec *server, BUFF *inout, if (m->new_connection != NULL) (*m->new_connection)(conn); } -#endif /* EAPI */ return conn; } -#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF) static void sock_disable_nagle(int s, struct sockaddr_in *sin_client) { /* The Nagle algorithm says that we should delay sending partial @@ -2989,10 +1885,6 @@ static void sock_disable_nagle(int s, struct sockaddr_in *sin_client) } } -#else -#define sock_disable_nagle(s, c) /* NOOP */ -#endif - static int make_sock(pool *p, const struct sockaddr_in *server) { int s; @@ -3015,27 +1907,9 @@ static int make_sock(pool *p, const struct sockaddr_in *server) exit(1); } - /* Solaris (probably versions 2.4, 2.5, and 2.5.1 with various levels - * of tcp patches) has some really weird bugs where if you dup the - * socket now it breaks things across SIGHUP restarts. It'll either - * be unable to bind, or it won't respond. - */ - - /* PR#1282 Unixware 1.x appears to have the same problem as solaris */ -#if defined (UW) && UW < 200 -#define WORKAROUND_SOLARIS_BUG -#endif - - /* PR#1973 NCR SVR4 systems appear to have the same problem */ -#if defined (MPRAS) -#define WORKAROUND_SOLARIS_BUG -#endif - -#ifndef WORKAROUND_SOLARIS_BUG s = ap_slack(s, AP_SLACK_HIGH); ap_note_cleanups_for_socket_ex(p, s, 1); /* arrange to close on exec or restart */ -#endif if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf, @@ -3045,7 +1919,6 @@ static int make_sock(pool *p, const struct sockaddr_in *server) exit(1); } one = 1; -#if defined(SO_KEEPALIVE) && !defined(MPE) if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(int)) < 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf, "make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr); @@ -3054,7 +1927,6 @@ static int make_sock(pool *p, const struct sockaddr_in *server) ap_unblock_alarms(); exit(1); } -#endif sock_disable_nagle(s, NULL); sock_enable_linger(s); @@ -3106,44 +1978,8 @@ static int make_sock(pool *p, const struct sockaddr_in *server) exit(1); } -#ifdef SO_ACCEPTFILTER - if (ap_acceptfilter) { -#ifndef ACCEPT_FILTER_NAME -#define ACCEPT_FILTER_NAME "httpready" -#ifdef __FreeBSD_version -#if __FreeBSD_version < 411000 /* httpready broken before 4.1.1 */ -#undef ACCEPT_FILTER_NAME -#define ACCEPT_FILTER_NAME "dataready" -#endif -#endif -#endif /* ! ACCEPT_FILTER_NAME */ - /* - * See htdocs/manual/misc/perf-bsd44.html for a discussion of - * how to enable this feature and various issues with it. - */ - struct accept_filter_arg af = { - ACCEPT_FILTER_NAME, "" - }; - if (setsockopt(s, SOL_SOCKET, SO_ACCEPTFILTER, &af, sizeof(af)) < 0) { - if (errno == ENOPROTOOPT) { - ap_log_error(APLOG_MARK, APLOG_INFO | APLOG_NOERRNO, server_conf, - "socket option SO_ACCEPTFILTER unknown on this machine. Continuing."); - } else { - ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_INFO, server_conf, - "make_sock: for %s, setsockopt: (SO_ACCEPTFILTER)", addr); - } - } - } -#endif - -#ifdef WORKAROUND_SOLARIS_BUG - s = ap_slack(s, AP_SLACK_HIGH); - - ap_note_cleanups_for_socket_ex(p, s, 1); /* arrange to close on exec or restart */ -#endif ap_unblock_alarms(); -#ifdef CHECK_FD_SETSIZE /* protect various fd_sets */ if (s >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, @@ -3154,7 +1990,6 @@ static int make_sock(pool *p, const struct sockaddr_in *server) closesocket(s); exit(1); } -#endif return s; } @@ -3258,17 +2093,6 @@ static void setup_listeners(pool *p) head_listener = ap_listeners; close_unused_listeners(); -#ifdef NO_SERIALIZED_ACCEPT - /* warn them about the starvation problem if they're using multiple - * sockets - */ - if (ap_listeners->next != ap_listeners) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, NULL, - "You cannot use multiple Listens safely on your system, " - "proceeding anyway. See src/PORTING, search for " - "SERIALIZED_ACCEPT."); - } -#endif } @@ -3299,75 +2123,23 @@ 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 EAPI printf(" -D EAPI\n"); -#endif #ifdef EAPI_MM printf(" -D EAPI_MM\n"); #ifdef EAPI_MM_CORE_PATH printf(" -D EAPI_MM_CORE_PATH=\"" EAPI_MM_CORE_PATH "\"\n"); #endif #endif -#ifdef BIG_SECURITY_HOLE - printf(" -D BIG_SECURITY_HOLE\n"); -#endif -#ifdef SECURITY_HOLE_PASS_AUTHORIZATION - printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n"); -#endif -#ifdef HAVE_MMAP printf(" -D HAVE_MMAP\n"); -#endif -#ifdef HAVE_SHMGET printf(" -D HAVE_SHMGET\n"); -#endif -#ifdef USE_MMAP_SCOREBOARD printf(" -D USE_MMAP_SCOREBOARD\n"); -#endif -#ifdef USE_SHMGET_SCOREBOARD - printf(" -D USE_SHMGET_SCOREBOARD\n"); -#endif -#ifdef USE_POSIX_SCOREBOARD - printf(" -D USE_POSIX_SCOREBOARD\n"); -#endif -#ifdef USE_MMAP_FILES printf(" -D USE_MMAP_FILES\n"); #ifdef MMAP_SEGMENT_SIZE printf(" -D MMAP_SEGMENT_SIZE=%ld\n",(long)MMAP_SEGMENT_SIZE); #endif -#endif /*USE_MMAP_FILES*/ -#ifdef NO_WRITEV - printf(" -D NO_WRITEV\n"); -#endif -#ifdef NO_LINGCLOSE - printf(" -D NO_LINGCLOSE\n"); -#endif -#ifdef HAVE_FCNTL_SERIALIZED_ACCEPT - printf(" -D HAVE_FCNTL_SERIALIZED_ACCEPT\n"); -#endif -#ifdef HAVE_FLOCK_SERIALIZED_ACCEPT printf(" -D HAVE_FLOCK_SERIALIZED_ACCEPT\n"); -#endif -#ifdef HAVE_USLOCK_SERIALIZED_ACCEPT - printf(" -D HAVE_USLOCK_SERIALIZED_ACCEPT\n"); -#endif -#ifdef HAVE_SYSVSEM_SERIALIZED_ACCEPT printf(" -D HAVE_SYSVSEM_SERIALIZED_ACCEPT\n"); -#endif -#ifdef HAVE_PTHREAD_SERIALIZED_ACCEPT - printf(" -D HAVE_PTHREAD_SERIALIZED_ACCEPT\n"); -#endif -#ifdef HAVE_NONE_SERIALIZED_ACCEPT - printf(" -D HAVE_NONE_SERIALIZED_ACCEPT\n"); -#endif -#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n"); -#endif -#ifdef NO_OTHER_CHILD - printf(" -D NO_OTHER_CHILD\n"); -#endif -#ifdef NO_RELIABLE_PIPED_LOGS - printf(" -D NO_RELIABLE_PIPED_LOGS\n"); -#endif #ifdef BUFFERED_LOGS printf(" -D BUFFERED_LOGS\n"); #ifdef PIPE_BUF @@ -3376,33 +2148,14 @@ static void show_compile_settings(void) #endif printf(" -D DYNAMIC_MODULE_LIMIT=%ld\n",(long)DYNAMIC_MODULE_LIMIT); printf(" -D HARD_SERVER_LIMIT=%ld\n",(long)HARD_SERVER_LIMIT); -#ifdef MULTITHREAD - printf(" -D MULTITHREAD\n"); -#endif -#ifdef NEED_HASHBANG_EMUL - printf(" -D NEED_HASHBANG_EMUL\n"); -#endif -#ifdef SHARED_CORE - printf(" -D SHARED_CORE\n"); -#endif -#ifdef SO_ACCEPTFILTER - printf(" -D SO_ACCEPTFILTER\n"); - printf(" -D ACCEPT_FILTER_NAME=\"" ACCEPT_FILTER_NAME "\"\n"); -#endif -#ifdef AP_ACCEPTFILTER_OFF - printf(" -D AP_ACCEPTFILTER_OFF\n"); -#endif /* This list displays the compiled-in default paths: */ #ifdef HTTPD_ROOT printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n"); #endif -#if defined(SUEXEC_BIN) && !defined(TPF) +#if defined(SUEXEC_BIN) printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n"); #endif -#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR) - printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n"); -#endif #ifdef DEFAULT_PIDLOG printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n"); #endif @@ -3452,7 +2205,6 @@ static void common_init(void) ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *)); ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *)); -#ifdef EAPI ap_hook_init(); ap_hook_configure("ap::buff::read", AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); @@ -3466,10 +2218,8 @@ static void common_init(void) AP_HOOK_SIG4(int,ptr,ptr,int), AP_HOOK_TOPMOST); ap_global_ctx = ap_ctx_new(NULL); -#endif /* EAPI */ } -#ifndef MULTITHREAD /***************************************************************** * Child process main loop. * The following vars are static to avoid getting clobbered by longjmp(); @@ -3552,9 +2302,7 @@ static void child_main(int child_num_arg) * Setup the jump buffers so that we can return here after a timeout */ ap_setjmp(jmpbuffer); -#ifdef SIGURG signal(SIGURG, timeout); -#endif if (signal(SIGALRM, alrm_handler) == SIG_ERR) { fprintf(stderr, "installing signal handler for SIGALRM failed, errno %u\n", errno); } @@ -3661,26 +2409,7 @@ static void child_main(int child_num_arg) */ switch (errno) { - -#ifdef EPROTO - /* EPROTO on certain older kernels really means - * ECONNABORTED, so we need to ignore it for them. - * See discussion in new-httpd archives nh.9701 - * search for EPROTO. - * - * Also see nh.9603, search for EPROTO: - * There is potentially a bug in Solaris 2.x x<6, - * and other boxes that implement tcp sockets in - * userland (i.e. on top of STREAMS). On these - * systems, EPROTO can actually result in a fatal - * loop. See PR#981 for example. It's hard to - * handle both uses of EPROTO. - */ - case EPROTO: -#endif -#ifdef ECONNABORTED case ECONNABORTED: -#endif /* Linux generates the rest of these, other tcp * stacks (i.e. bsd) tend to hide them behind * getsockopt() interfaces. They occur when @@ -3689,20 +2418,11 @@ static void child_main(int child_num_arg) * in the kernel but before userland has picked * up the socket. */ -#ifdef ECONNRESET case ECONNRESET: -#endif -#ifdef ETIMEDOUT case ETIMEDOUT: -#endif -#ifdef EHOSTUNREACH case EHOSTUNREACH: -#endif -#ifdef ENETUNREACH case ENETUNREACH: -#endif break; -#ifdef ENETDOWN case ENETDOWN: /* * When the network layer has been shut down, there @@ -3721,7 +2441,6 @@ static void child_main(int child_num_arg) ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf, "accept: giving up."); clean_child_exit(APEXIT_CHILDFATAL); -#endif /*ENETDOWN*/ default: ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, @@ -3756,7 +2475,6 @@ static void child_main(int child_num_arg) ap_note_cleanups_for_socket_ex(ptrans, csd, 1); /* protect various fd_sets */ -#ifdef CHECK_FD_SETSIZE if (csd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "[csd] filedescriptor (%u) larger than FD_SETSIZE (%u) " @@ -3764,7 +2482,6 @@ static void child_main(int child_num_arg) "larger FD_SETSIZE", csd, FD_SETSIZE); continue; } -#endif /* * We now have a connection, so set it up with the appropriate @@ -3787,36 +2504,7 @@ static void child_main(int child_num_arg) conn_io = ap_bcreate(ptrans, B_RDWR | B_SOCKET); -#ifdef B_SFIO - (void) sfdisc(conn_io->sf_in, SF_POPDISC); - sfdisc(conn_io->sf_in, bsfio_new(conn_io->pool, conn_io)); - sfsetbuf(conn_io->sf_in, NULL, 0); - - (void) sfdisc(conn_io->sf_out, SF_POPDISC); - sfdisc(conn_io->sf_out, bsfio_new(conn_io->pool, conn_io)); - sfsetbuf(conn_io->sf_out, NULL, 0); -#endif - dupped_csd = csd; -#if defined(NEED_DUPPED_CSD) - if ((dupped_csd = dup(csd)) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "dup: couldn't duplicate csd"); - dupped_csd = csd; /* Oh well... */ - } - ap_note_cleanups_for_socket_ex(ptrans, dupped_csd, 1); - - /* protect various fd_sets */ -#ifdef CHECK_FD_SETSIZE - if (dupped_csd >= FD_SETSIZE) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, - "[dupped_csd] filedescriptor (%u) larger than FD_SETSIZE (%u) " - "found, you probably need to rebuild Apache with a " - "larger FD_SETSIZE", dupped_csd, FD_SETSIZE); - continue; - } -#endif -#endif ap_bpushfd(conn_io, csd, dupped_csd); current_conn = new_connection(ptrans, server_conf, conn_io, @@ -3854,9 +2542,7 @@ static void child_main(int child_num_arg) ap_sync_scoreboard_image(); if (ap_scoreboard_image->global.running_generation != ap_my_generation) { -#ifdef EAPI ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ ap_bclose(conn_io); clean_child_exit(0); } @@ -3884,12 +2570,6 @@ static void child_main(int child_num_arg) * client has ACKed our FIN and/or has stopped sending us data. */ -#ifdef NO_LINGCLOSE -#ifdef EAPI - ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ - ap_bclose(conn_io); /* just close it */ -#else if (r && r->connection && !r->connection->aborted && r->connection->client @@ -3898,13 +2578,10 @@ static void child_main(int child_num_arg) lingering_close(r); } else { -#ifdef EAPI ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ ap_bsetflag(conn_io, B_EOUT, 1); ap_bclose(conn_io); } -#endif } } @@ -3920,9 +2597,7 @@ static int make_child(server_rec *s, int slot, time_t now) if (one_process) { signal(SIGHUP, just_die); signal(SIGINT, just_die); -#ifdef SIGQUIT signal(SIGQUIT, SIG_DFL); -#endif signal(SIGTERM, just_die); child_main(slot); } @@ -3951,18 +2626,6 @@ static int make_child(server_rec *s, int slot, time_t now) } if (!pid) { -#ifdef AIX_BIND_PROCESSOR -/* by default AIX binds to a single processor - * this bit unbinds children which will then bind to another cpu - */ -#include <sys/processor.h> - int status = bindprocessor(BINDPROCESS, (int)getpid(), - PROCESSOR_CLASS_ANY); - if (status != OK) { - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, server_conf, - "processor unbind failed %d", status); - } -#endif RAISE_SIGSTOP(MAKE_CHILD); MONCONTROL(1); /* Disable the restart signal handlers and enable the just_die stuff. @@ -3975,16 +2638,8 @@ static int make_child(server_rec *s, int slot, time_t now) child_main(slot); } -#ifdef OPTIMIZE_TIMEOUTS ap_scoreboard_image->parent[slot].last_rtime = now; -#endif ap_scoreboard_image->parent[slot].pid = pid; -#ifdef SCOREBOARD_FILE - lseek(scoreboard_fd, XtOffsetOf(scoreboard, parent[slot]), 0); - force_write(scoreboard_fd, &ap_scoreboard_image->parent[slot], - sizeof(parent_score)); -#endif - return 0; } @@ -4086,7 +2741,6 @@ static void perform_idle_server_maintenance(void) ++total_non_dead; last_non_dead = i; -#ifdef OPTIMIZE_TIMEOUTS if (ss->timeout_len) { /* if it's a live server, with a live timeout then * start checking its timeout */ @@ -4103,7 +2757,6 @@ static void perform_idle_server_maintenance(void) kill(ps->pid, SIG_TIMEOUT_KILL); } } -#endif } } max_daemons_limit = last_non_dead + 1; @@ -4188,8 +2841,6 @@ static void process_child_status(int pid, ap_wait_t status) case SIGKILL: break; default: -#ifdef SYS_SIGLIST -#ifdef WCOREDUMP if (WCOREDUMP(status)) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, @@ -4200,20 +2851,11 @@ static void process_child_status(int pid, ap_wait_t status) ap_coredump_dir); } else { -#endif ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, "child pid %d exit signal %s (%d)", pid, SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status)); -#ifdef WCOREDUMP } -#endif -#else - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, - server_conf, - "child pid %d exit signal %d", - pid, WTERMSIG(status)); -#endif } } } @@ -4249,12 +2891,6 @@ static void standalone_main(int argc, char **argv) if (!is_graceful) { ap_restart_time = time(NULL); } -#ifdef SCOREBOARD_FILE - else if (scoreboard_fd != -1) { - ap_kill_cleanup(pconf, NULL, cleanup_scoreboard_file); - ap_kill_cleanups_for_fd(pconf, scoreboard_fd); - } -#endif ap_clear_pool(pconf); ptrans = ap_make_sub_pool(pconf); @@ -4328,13 +2964,6 @@ static void standalone_main(int argc, char **argv) if (!is_graceful) { reinit_scoreboard(pconf); } -#ifdef SCOREBOARD_FILE - else { - ap_scoreboard_fname = ap_server_root_relative(pconf, ap_scoreboard_fname); - ap_note_cleanups_for_fd_ex(pconf, scoreboard_fd, 1); /* close on exec */ - } -#endif - set_signals(); if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */ @@ -4402,11 +3031,9 @@ static void standalone_main(int argc, char **argv) make_child(server_conf, child_slot, time(NULL)); --remaining_children_to_start; } -#ifndef NO_OTHER_CHILD } else if (reap_other_child(pid, status) == 0) { /* handled */ -#endif } else if (is_graceful) { /* Great, we've probably just lost a slot in the @@ -4484,9 +3111,7 @@ static void standalone_main(int argc, char **argv) update_scoreboard_global(); if (is_graceful) { -#ifndef SCOREBOARD_FILE int i; -#endif ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf, "SIGUSR1 received. Doing graceful restart"); @@ -4494,7 +3119,6 @@ static void standalone_main(int argc, char **argv) if (ap_killpg(pgrp, SIGUSR1) < 0) { ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "killpg SIGUSR1"); } -#ifndef SCOREBOARD_FILE /* This is mostly for debugging... so that we know what is still * gracefully dealing with existing request. But we can't really * do it if we're in a SCOREBOARD_FILE because it'll cause @@ -4506,7 +3130,6 @@ static void standalone_main(int argc, char **argv) ap_scoreboard_image->servers[i].status = SERVER_GRACEFUL; } } -#endif } else { /* Kill 'em off */ @@ -4529,12 +3152,6 @@ void STANDALONE_MAIN(int argc, char **argv); extern char *optarg; extern int optind; -/* Cygwin 1.x SHARED_CORE support needs REALMAIN to be declared as dllexport, - * so we can later while SHARED_CORE_BOOTSTRAP is compiled and linked see the - * dllimport for it. -- Stipe Tolj <tolj@wapme-systems.de> - */ - - int REALMAIN(int argc, char *argv[]) { int c; @@ -4542,21 +3159,6 @@ int REALMAIN(int argc, char *argv[]) int sock_out; char *s; -#ifdef SecureWare - if (set_auth_parameters(argc, argv) < 0) - perror("set_auth_parameters"); - if (getluid() < 0) - if (setluid(getuid()) < 0) - perror("setluid"); - if (setreuid(0, 0) < 0) - perror("setreuid"); -#endif - -#ifdef SOCKS - SOCKSinit(argv[0]); -#endif - - MONCONTROL(0); common_init(); @@ -4626,15 +3228,6 @@ int REALMAIN(int argc, char *argv[]) raise_sigstop_flags = atoi(optarg); break; #endif -#ifdef SHARED_CORE - case 'R': - /* just ignore this option here, because it has only - * effect when SHARED_CORE is used and then it was - * already handled in the Shared Core Bootstrap - * program. - */ - break; -#endif case 'S': ap_dump_settings = 1; break; @@ -4655,31 +3248,19 @@ int REALMAIN(int argc, char *argv[]) usage(argv[0]); } } -#ifdef EAPI ap_init_alloc_shared(TRUE); -#endif ap_suexec_enabled = init_suexec(); server_conf = ap_read_config(pconf, ptrans, ap_server_confname); -#ifdef EAPI ap_init_alloc_shared(FALSE); -#endif if (ap_configtestonly) { fprintf(stderr, "Syntax OK\n"); -#ifdef EAPI clean_parent_exit(0); -#else - exit(0); -#endif } if (ap_dump_settings) { -#ifdef EAPI clean_parent_exit(0); -#else - exit(0); -#endif } child_timeouts = !ap_standalone || one_process; @@ -4757,1636 +3338,13 @@ int REALMAIN(int argc, char *argv[]) ap_destroy_pool(r->pool); } -#ifdef EAPI ap_call_close_connection_hook(conn); -#endif /* EAPI */ ap_bclose(cio); } exit(0); } -#else /* ndef MULTITHREAD */ - - -/********************************************************************** - * Multithreaded implementation - * - * This code is fairly specific to Win32. - * - * The model used to handle requests is a set of threads. One "main" - * thread listens for new requests. When something becomes - * available, it does a select and places the newly available socket - * onto a list of "jobs" (add_job()). Then any one of a fixed number - * of "worker" threads takes the top job off the job list with - * remove_job() and handles that connection to completion. After - * the connection has finished the thread is free to take another - * job from the job list. - * - * In the code, the "main" thread is running within the worker_main() - * function. The first thing this function does is create the - * worker threads, which operate in the child_sub_main() function. The - * main thread then goes into a loop within worker_main() where they - * do a select() on the listening sockets. The select times out once - * per second so that the thread can check for an "exit" signal - * from the parent process (see below). If this signal is set, the - * thread can exit, but only after it has accepted all incoming - * connections already in the listen queue (since Win32 appears - * to through away listened but unaccepted connections when a - * process dies). - * - * Because the main and worker threads exist within a single process - * they are vulnerable to crashes or memory leaks (crashes can also - * be caused within modules, of course). There also needs to be a - * mechanism to perform restarts and shutdowns. This is done by - * creating the main & worker threads within a subprocess. A - * main process (the "parent process") creates one (or more) - * processes to do the work, then the parent sits around waiting - * for the working process to die, in which case it starts a new - * one. The parent process also handles restarts (by creating - * a new working process then signalling the previous working process - * exit ) and shutdowns (by signalling the working process to exit). - * The parent process operates within the master_main() function. This - * process also handles requests from the service manager (NT only). - * - * Signalling between the parent and working process uses a Win32 - * event. Each child has a unique name for the event, which is - * passed to it with the -Z argument when the child is spawned. The - * parent sets (signals) this event to tell the child to die. - * At present all children do a graceful die - they finish all - * current jobs _and_ empty the listen queue before they exit. - * A non-graceful die would need a second event. The -Z argument in - * the child is also used to create the shutdown and restart events, - * since the prefix (apPID) contains the parent process PID. - * - * The code below starts with functions at the lowest level - - * worker threads, and works up to the top level - the main() - * function of the parent process. - * - * The scoreboard (in process memory) contains details of the worker - * threads (within the active working process). There is no shared - * "scoreboard" between processes, since only one is ever active - * at once (or at most, two, when one has been told to shutdown but - * is processes outstanding requests, and a new one has been started). - * This is controlled by a "start_mutex" which ensures only one working - * process is active at once. - **********************************************************************/ - -/* The code protected by #ifdef UNGRACEFUL_RESTARTS/#endif sections - * could implement a sort-of ungraceful restart for Win32. instead of - * graceful restarts. - * - * However it does not work too well because it does not intercept a - * connection already in progress (in child_sub_main()). We'd have to - * get that to poll on the exit event. - */ - -/* - * Definition of jobs, shared by main and worker threads. - */ - -typedef struct joblist_s { - struct joblist_s *next; - int sock; -} joblist; - -/* - * Globals common to main and worker threads. This structure is not - * used by the parent process. - */ - -typedef struct globals_s { -#ifdef UNGRACEFUL_RESTART - HANDLE thread_exit_event; -#else - int exit_now; -#endif - semaphore *jobsemaphore; - joblist *jobhead; - joblist *jobtail; - mutex *jobmutex; - int jobcount; -} globals; - -globals allowed_globals = -{0, NULL, NULL, NULL, NULL, 0}; - -/* - * add_job()/remove_job() - add or remove an accepted socket from the - * list of sockets connected to clients. allowed_globals.jobmutex protects - * against multiple concurrent access to the linked list of jobs. - */ - -void add_job(int sock) -{ - joblist *new_job; - - ap_assert(allowed_globals.jobmutex); - - /* TODO: If too many jobs in queue, sleep, check for problems */ - ap_acquire_mutex(allowed_globals.jobmutex); - new_job = (joblist *) malloc(sizeof(joblist)); - if (new_job == NULL) { - fprintf(stderr, "Ouch! Out of memory in add_job()!\n"); - } - new_job->next = NULL; - new_job->sock = sock; - if (allowed_globals.jobtail != NULL) - allowed_globals.jobtail->next = new_job; - allowed_globals.jobtail = new_job; - if (!allowed_globals.jobhead) - allowed_globals.jobhead = new_job; - allowed_globals.jobcount++; - release_semaphore(allowed_globals.jobsemaphore); - ap_release_mutex(allowed_globals.jobmutex); -} - -int remove_job(int csd) -{ - static reported = 0; - static active_threads = 0; - joblist *job; - int sock; - - /* Decline decrementing active_threads count on the first call - * to remove_job. csd == -1 implies that this is the thread's - * first call to remove_job. - */ - if (csd != -1) { - active_threads--; - } - -#ifdef UNGRACEFUL_RESTART - HANDLE hObjects[2]; - int rv; - - hObjects[0] = allowed_globals.jobsemaphore; - hObjects[1] = allowed_globals.thread_exit_event; - - rv = WaitForMultipleObjects(2, hObjects, FALSE, INFINITE); - ap_assert(rv != WAIT_FAILED); - if (rv == WAIT_OBJECT_0 + 1) { - /* thread_exit_now */ - APD1("thread got exit now event"); - return -1; - } - /* must be semaphore */ -#else - acquire_semaphore(allowed_globals.jobsemaphore); -#endif - ap_assert(allowed_globals.jobmutex); - -#ifdef UNGRACEFUL_RESTART - if (!allowed_globals.jobhead) { -#else - ap_acquire_mutex(allowed_globals.jobmutex); - if (allowed_globals.exit_now && !allowed_globals.jobhead) { -#endif - ap_release_mutex(allowed_globals.jobmutex); - return (-1); - } - - job = allowed_globals.jobhead; - ap_assert(job); - allowed_globals.jobhead = job->next; - if (allowed_globals.jobhead == NULL) - allowed_globals.jobtail = NULL; - - ap_release_mutex(allowed_globals.jobmutex); - sock = job->sock; - free(job); - - /* If sock == -1 then the thread is about to exit so - * don't count it as active. - */ - if (sock != -1) - active_threads++; - - if (!reported && (active_threads == ap_threads_per_child)) { - reported = 1; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf, - "Server ran out of threads to serve requests. Consider " - "raising the ThreadsPerChild setting"); - } - return (sock); -} - -/* - * child_sub_main() - this is the main loop for the worker threads - * - * Each thread runs within this function. They wait within remove_job() - * for a job to become available, then handle all the requests on that - * connection until it is closed, then return to remove_job(). - * - * The worker thread will exit when it removes a job which contains - * socket number -1. This provides a graceful thread exit, since - * it will never exit during a connection. - * - * This code in this function is basically equivalent to the child_main() - * from the multi-process (Unix) environment, except that we - * - * - do not call child_init_modules (child init API phase) - * - block in remove_job, and when unblocked we have an already - * accepted socket, instead of blocking on a mutex or select(). - */ - -static void child_sub_main(int child_num) -{ - NET_SIZE_T clen; - struct sockaddr sa_server; - struct sockaddr sa_client; - pool *ptrans; - int requests_this_child = 0; - int csd = -1; - int dupped_csd = -1; - int srv = 0; - - ap_thread_count++; - ptrans = ap_make_sub_pool(pconf); - - (void) ap_update_child_status(child_num, SERVER_READY, (request_rec *) NULL); - - /* - * Setup the jump buffers so that we can return here after a timeout. - */ -#if defined(USE_LONGJMP) - setjmp(jmpbuffer); -#else - sigsetjmp(jmpbuffer, 1); -#endif -#if defined(SIGURG) - signal(SIGURG, timeout); -#endif - - - while (1) { - BUFF *conn_io; - request_rec *r; - - /* - * (Re)initialize this child to a pre-connection state. - */ - - ap_set_callback_and_alarm(NULL, 0); /* Cancel any outstanding alarms */ - timeout_req = NULL; /* No request in progress */ - current_conn = NULL; - ap_clear_pool(ptrans); - - (void) ap_update_child_status(child_num, SERVER_READY, - (request_rec *) NULL); - - /* Get job from the job list. This will block until a job is ready. - * If -1 is returned then the main thread wants us to exit. - */ - csd = remove_job(csd); - if (csd == -1) - break; /* time to exit */ - - requests_this_child++; - - ap_note_cleanups_for_socket_ex(ptrans, csd, 1); - - /* - * We now have a connection, so set it up with the appropriate - * socket options, file descriptors, and read/write buffers. - */ - - clen = sizeof(sa_server); - if (getsockname(csd, &sa_server, &clen) < 0) { - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "getsockname"); - continue; - } - clen = sizeof(sa_client); - if ((getpeername(csd, &sa_client, &clen)) < 0) { - /* get peername will fail if the input isn't a socket */ - perror("getpeername"); - memset(&sa_client, '\0', sizeof(sa_client)); - } - - sock_disable_nagle(csd, (struct sockaddr_in *)&sa_client); - - (void) ap_update_child_status(child_num, SERVER_BUSY_READ, - (request_rec *) NULL); - - conn_io = ap_bcreate(ptrans, B_RDWR | B_SOCKET); - dupped_csd = csd; -#if defined(NEED_DUPPED_CSD) - if ((dupped_csd = dup(csd)) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "dup: couldn't duplicate csd"); - dupped_csd = csd; /* Oh well... */ - } - ap_note_cleanups_for_socket_ex(ptrans, dupped_csd, 1); -#endif - ap_bpushfd(conn_io, csd, dupped_csd); - - current_conn = new_connection(ptrans, server_conf, conn_io, - (struct sockaddr_in *) &sa_client, - (struct sockaddr_in *) &sa_server, - child_num); - - /* - * Read and process each request found on our connection - * until no requests are left or we decide to close. - */ - while ((r = ap_read_request(current_conn)) != NULL) { - (void) ap_update_child_status(child_num, SERVER_BUSY_WRITE, r); - - if (r->status == HTTP_OK) - ap_process_request(r); - - if (ap_extended_status) - increment_counts(child_num, r); - if (!current_conn->keepalive || current_conn->aborted) - break; - /* If the server is shutting down, do not allow anymore requests - * to be handled on the keepalive connection. Leave the thread - * alive to drain the job queue. This check is particularly - * important on the threaded server to allow the process to be - * quickly taken down cleanly. - */ - if (allowed_globals.exit_now) - break; - ap_destroy_pool(r->pool); - (void) ap_update_child_status(child_num, SERVER_BUSY_KEEPALIVE, - (request_rec *) NULL); - - ap_sync_scoreboard_image(); - } - - /* - * Close the connection, being careful to send out whatever is still - * in our buffers. If possible, try to avoid a hard close until the - * client has ACKed our FIN and/or has stopped sending us data. - */ - ap_kill_cleanups_for_socket(ptrans, csd); - -#ifdef NO_LINGCLOSE -#ifdef EAPI - ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ - ap_bclose(conn_io); /* just close it */ -#else - if (r && r->connection - && !r->connection->aborted - && r->connection->client - && (r->connection->client->fd >= 0)) { - - lingering_close(r); - } - else { -#ifdef EAPI - ap_call_close_connection_hook(current_conn); -#endif /* EAPI */ - ap_bsetflag(conn_io, B_EOUT, 1); - ap_bclose(conn_io); - } -#endif - } - ap_destroy_pool(ptrans); - (void) ap_update_child_status(child_num, SERVER_DEAD, NULL); - - ap_thread_count--; -} - - -void child_main(int child_num_arg) -{ - /* - * Only reason for this function, is to pass in - * arguments to child_sub_main() on its stack so - * that longjump doesn't try to corrupt its local - * variables and I don't need to make those - * damn variables static/global - */ - child_sub_main(child_num_arg); -} - - - -void cleanup_thread(thread **handles, int *thread_cnt, int thread_to_clean) -{ - int i; - - free_thread(handles[thread_to_clean]); - for (i = thread_to_clean; i < ((*thread_cnt) - 1); i++) - handles[i] = handles[i + 1]; - (*thread_cnt)--; -} -/***************************************************************** - * Executive routines. - */ - -extern void main_control_server(void *); /* in hellop.c */ - -event *exit_event; -mutex *start_mutex; - -#define MAX_SIGNAL_NAME 30 /* Long enough for apPID_shutdown, where PID is an int */ -char signal_name_prefix[MAX_SIGNAL_NAME]; -char signal_restart_name[MAX_SIGNAL_NAME]; -char signal_shutdown_name[MAX_SIGNAL_NAME]; - -#define MAX_SELECT_ERRORS 100 - -/* - * Initialise the signal names, in the global variables signal_name_prefix, - * signal_restart_name and signal_shutdown_name. - */ - -void setup_signal_names(char *prefix) -{ - ap_snprintf(signal_name_prefix, sizeof(signal_name_prefix), prefix); - ap_snprintf(signal_shutdown_name, sizeof(signal_shutdown_name), - "%s_shutdown", signal_name_prefix); - ap_snprintf(signal_restart_name, sizeof(signal_restart_name), - "%s_restart", signal_name_prefix); - - APD2("signal prefix %s", signal_name_prefix); -} - -static void setup_inherited_listeners(pool *p) -{ - HANDLE pipe; - listen_rec *lr; - int fd; - WSAPROTOCOL_INFO WSAProtocolInfo; - DWORD BytesRead; - - /* Setup the listeners */ - listenmaxfd = -1; - FD_ZERO(&listenfds); - - /* Open the pipe to the parent process to receive the inherited socket - * data. The sockets have been set to listening in the parent process. - */ - pipe = GetStdHandle(STD_INPUT_HANDLE); - for (lr = ap_listeners; lr; lr = lr->next) { - if (!ReadFile(pipe, &WSAProtocolInfo, sizeof(WSAPROTOCOL_INFO), - &BytesRead, (LPOVERLAPPED) NULL)) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, - "setup_inherited_listeners: Unable to read socket data from parent"); - signal_parent(0); /* tell parent to die */ - exit(1); - } - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, - "BytesRead = %d WSAProtocolInfo = %x20", BytesRead, WSAProtocolInfo); - fd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, - &WSAProtocolInfo, 0, 0); - if (fd == INVALID_SOCKET) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR|APLOG_CRIT, server_conf, - "setup_inherited_listeners: WSASocket failed to open the inherited socket."); - signal_parent(0); /* tell parent to die */ - exit(1); - } - if (fd >= 0) { - FD_SET(fd, &listenfds); - if (fd > listenmaxfd) - listenmaxfd = fd; - } - ap_note_cleanups_for_socket_ex(p, fd, 1); - lr->fd = fd; - if (lr->next == NULL) { - /* turn the list into a ring */ - lr->next = ap_listeners; - break; - } - } - head_listener = ap_listeners; - close_unused_listeners(); - CloseHandle(pipe); - return; -} - -/* - * worker_main() is main loop for the child process. The loop in - * this function becomes the controlling thread for the actually working - * threads (which run in a loop in child_sub_main()). - */ - -void worker_main(void) -{ - int nthreads; - fd_set main_fds; - int srv; - int clen; - int csd; - struct sockaddr_in sa_client; - int total_jobs = 0; - thread **child_handles; - int rv; - time_t end_time; - int i; - struct timeval tv; - int wait_time = 1; - int max_jobs_per_exe; - int max_jobs_after_exit_request; - HANDLE hObjects[2]; - - int count_select_errors = 0; - pool *pchild; - - pchild = ap_make_sub_pool(pconf); - - ap_standalone = 1; - sd = -1; - nthreads = ap_threads_per_child; - max_jobs_after_exit_request = ap_excess_requests_per_child; - max_jobs_per_exe = ap_max_requests_per_child; - if (nthreads <= 0) - nthreads = 40; - if (max_jobs_per_exe <= 0) - max_jobs_per_exe = 0; - if (max_jobs_after_exit_request <= 0) - max_jobs_after_exit_request = max_jobs_per_exe / 10; - - if (!one_process) - detach(); - - my_pid = getpid(); - - ++ap_my_generation; - - copy_listeners(pconf); - ap_restart_time = time(NULL); - - reinit_scoreboard(pconf); - - /* - * Wait until we have permission to start accepting connections. - * start_mutex is used to ensure that only one child ever - * goes into the listen/accept loop at once. Also wait on exit_event, - * in case we (this child) is told to die before we get a chance to - * serve any requests. - */ - hObjects[0] = (HANDLE)start_mutex; - hObjects[1] = (HANDLE)exit_event; - rv = WaitForMultipleObjects(2, hObjects, FALSE, INFINITE); - if (rv == WAIT_FAILED) { - ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_WIN32ERROR, server_conf, - "Waiting for start_mutex or exit_event -- process will exit"); - - ap_destroy_pool(pchild); - cleanup_scoreboard(); - exit(1); - } - if (rv == WAIT_OBJECT_0 + 1) { - /* exit event signalled - exit now */ - ap_destroy_pool(pchild); - cleanup_scoreboard(); - exit(0); - } - /* start_mutex obtained, continue into the select() loop */ - if (one_process) { - setup_listeners(pconf); - } else { - /* Get listeners from the parent process */ - setup_inherited_listeners(pconf); - } - - if (listenmaxfd == -1) { - /* Help, no sockets were made, better log something and exit */ - ap_log_error(APLOG_MARK, APLOG_CRIT|APLOG_NOERRNO, NULL, - "No sockets were created for listening"); - - signal_parent(0); /* tell parent to die */ - - ap_destroy_pool(pchild); - cleanup_scoreboard(); - exit(1); - } - set_signals(); - - /* - * - Initialize allowed_globals - * - Create the thread table - * - Spawn off threads - * - Create listen socket set (done above) - * - loop { - * wait for request - * create new job - * } while (!time to exit) - * - Close all listeners - * - Wait for all threads to complete - * - Exit - */ - - ap_child_init_modules(pconf, server_conf); - - allowed_globals.jobsemaphore = create_semaphore(0); - allowed_globals.jobmutex = ap_create_mutex(NULL); - - /* spawn off the threads */ - child_handles = (thread *) alloca(nthreads * sizeof(int)); - for (i = 0; i < nthreads; i++) { - child_handles[i] = create_thread((void (*)(void *)) child_main, (void *) i); - if (child_handles[i] == 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "create_thread rc = %d", errno); - } - } - if (nthreads > max_daemons_limit) { - max_daemons_limit = nthreads; - } - - while (1) { - if (max_jobs_per_exe && (total_jobs > max_jobs_per_exe)) { - /* Reached MaxRequestsPerChild. Stop accepting new connections - * and signal the parent to start a new child process. - */ - ap_start_restart(1); - break; - } - /* Always check for the exit event being signaled. - */ - rv = WaitForSingleObject(exit_event, 0); - ap_assert((rv == WAIT_TIMEOUT) || (rv == WAIT_OBJECT_0)); - if (rv == WAIT_OBJECT_0) { - APD1("child: exit event signalled, exiting"); - break; - } - - tv.tv_sec = wait_time; - tv.tv_usec = 0; - memcpy(&main_fds, &listenfds, sizeof(fd_set)); - - srv = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, &tv); - - if (srv == 0) { - count_select_errors = 0; /* reset count of errors */ - continue; - } - else if (srv == SOCKET_ERROR) { - if (h_errno != WSAEINTR) { - /* A "real" error occurred, log it and increment the count of - * select errors. This count is used to ensure we don't go into - * a busy loop of continuous errors. - */ - ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, - "select failed with errno %d", h_errno); - count_select_errors++; - if (count_select_errors > MAX_SELECT_ERRORS) { - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, server_conf, - "Too many errors in select loop. Child process exiting."); - break; - } - } - continue; - } else { - listen_rec *lr; - - lr = find_ready_listener(&main_fds); - if (lr != NULL) { - sd = lr->fd; - } - } - do { - clen = sizeof(sa_client); - csd = accept(sd, (struct sockaddr *) &sa_client, &clen); - if (csd == INVALID_SOCKET) { - csd = -1; - } - } while (csd < 0 && h_errno == WSAEINTR); - - if (csd < 0) { - if (h_errno != WSAECONNABORTED) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "accept: (client socket) failed with errno = %d",h_errno); - } - } - else { - add_job(csd); - total_jobs++; - } - } - - APD2("process PID %d exiting", my_pid); - - /* Get ready to shutdown and exit */ - allowed_globals.exit_now = 1; - ap_release_mutex(start_mutex); - -#ifdef UNGRACEFUL_RESTART - SetEvent(allowed_globals.thread_exit_event); -#else - for (i = 0; i < nthreads; i++) { - add_job(-1); - } -#endif - - APD2("process PID %d waiting for worker threads to exit", my_pid); - /* Wait for all your children */ - end_time = time(NULL) + 180; - while (nthreads) { - rv = wait_for_many_objects(nthreads, child_handles, - end_time - time(NULL)); - if (rv != WAIT_TIMEOUT) { - rv = rv - WAIT_OBJECT_0; - ap_assert((rv >= 0) && (rv < nthreads)); - cleanup_thread(child_handles, &nthreads, rv); - continue; - } - break; - } - - APD2("process PID %d killing remaining worker threads", my_pid); - for (i = 0; i < nthreads; i++) { - kill_thread(child_handles[i]); - free_thread(child_handles[i]); - } -#ifdef UNGRACEFUL_RESTART - ap_assert(CloseHandle(allowed_globals.thread_exit_event)); -#endif - destroy_semaphore(allowed_globals.jobsemaphore); - ap_destroy_mutex(allowed_globals.jobmutex); - - ap_child_exit_modules(pconf, server_conf); - ap_destroy_pool(pchild); - - cleanup_scoreboard(); - - APD2("process PID %d exited", my_pid); - clean_parent_exit(0); -} /* standalone_main */ - -/* - * Spawn a child Apache process. The child process has the command line arguments from - * argc and argv[], plus a -Z argument giving the name of an event. The child should - * open and poll or wait on this event. When it is signalled, the child should die. - * prefix is a prefix string for the event name. - * - * The child_num argument on entry contains a serial number for this child (used to create - * a unique event name). On exit, this number will have been incremented by one, ready - * for the next call. - * - * On exit, the value pointed to be *ev will contain the event created - * to signal the new child process. - * - * The return value is the handle to the child process if successful, else -1. If -1 is - * returned the error will already have been logged by ap_log_error(). - */ - -/********************************************************************** - * master_main - this is the parent (main) process. We create a - * child process to do the work, then sit around waiting for either - * the child to exit, or a restart or exit signal. If the child dies, - * we just respawn a new one. If we have a shutdown or graceful restart, - * tell the child to die when it is ready. If it is a non-graceful - * restart, force the child to die immediately. - **********************************************************************/ - -#define MAX_PROCESSES 50 /* must be < MAX_WAIT_OBJECTS-1 */ - -static void cleanup_process(HANDLE *handles, HANDLE *events, int position, int *processes) -{ - int i; - int handle = 0; - - CloseHandle(handles[position]); - CloseHandle(events[position]); - - handle = (int)handles[position]; - - for (i = position; i < (*processes)-1; i++) { - handles[i] = handles[i + 1]; - events[i] = events[i + 1]; - } - (*processes)--; - - APD4("cleanup_processes: removed child in slot %d handle %d, max=%d", position, handle, *processes); -} - -static int create_process(pool *p, HANDLE *handles, HANDLE *events, - int *processes, int *child_num, char *kill_event_name, int argc, char **argv) -{ - - int rv, i; - HANDLE kill_event; - char buf[1024]; - char exit_event_name[40]; /* apPID_C# */ - char *pCommand; - - STARTUPINFO si; /* Filled in prior to call to CreateProcess */ - PROCESS_INFORMATION pi; /* filled in on call to CreateProces */ - LPWSAPROTOCOL_INFO lpWSAProtocolInfo; - listen_rec *lr; - DWORD BytesWritten; - HANDLE hPipeRead = NULL; - HANDLE hPipeWrite = NULL; - HANDLE hPipeWriteDup; - HANDLE hNullOutput = NULL; - HANDLE hShareError = NULL; - HANDLE hCurrentProcess; - SECURITY_ATTRIBUTES sa = {0}; - - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - - /* Build the command line. Should look something like this: - * C:/apache/bin/apache.exe -Z exit_event -f ap_server_confname - * First, get the path to the executable... - */ - rv = GetModuleFileName(NULL, buf, sizeof(buf)); - if (rv == sizeof(buf)) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Path to Apache process too long"); - return -1; - } else if (rv == 0) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: GetModuleFileName() returned NULL for current process."); - return -1; - } - - /* Create the exit event (apPID_C#). Parent signals this event to tell the - * child to exit - */ - ap_snprintf(exit_event_name, sizeof(exit_event_name), "%s_C%d", kill_event_name, ++(*child_num)); - kill_event = CreateEvent(NULL, TRUE, FALSE, exit_event_name); - if (!kill_event) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Could not create exit event for child process"); - return -1; - } - - /* service children must be created with the -z option, - * while console mode (interactive apache) children are created - * with the -Z option - */ - pCommand = ap_psprintf(p, "\"%s\" -%c %s -f \"%s\"", buf, - isProcessService() ? 'z' : 'Z', - exit_event_name, ap_server_confname); - - for (i = 1; i < argc; i++) { - if ((argv[i][0] == '-') && ((argv[i][1] == 'k') || (argv[i][1] == 'n'))) - ++i; - else - pCommand = ap_pstrcat(p, pCommand, " \"", argv[i], "\"", NULL); - } - - /* Create a pipe to send socket info to the child */ - if (!CreatePipe(&hPipeRead, &hPipeWrite, &sa, 0)) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Unable to create pipe to child process.\n"); - return -1; - } - - /* Open a null handle to soak info from the child */ - hNullOutput = CreateFile("nul", GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sa, OPEN_EXISTING, 0, NULL); - if (hNullOutput == INVALID_HANDLE_VALUE) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Unable to create null output pipe for child process.\n"); - return -1; - } - - /* Child's initial stderr -> our main server error log (or, failing that, stderr) */ - if (server_conf->error_log) { - hShareError = (HANDLE)_get_osfhandle(fileno(server_conf->error_log)); - if (hShareError == INVALID_HANDLE_VALUE) { - hShareError = GetStdHandle(STD_ERROR_HANDLE); - } - } - - hCurrentProcess = GetCurrentProcess(); - if (DuplicateHandle(hCurrentProcess, hPipeWrite, hCurrentProcess, - &hPipeWriteDup, 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - CloseHandle(hPipeWrite); - hPipeWrite = hPipeWriteDup; - } - - /* Give the read in of the pipe (hPipeRead) to the child as stdin. The - * parent will write the socket data to the child on this pipe. - */ - memset(&si, 0, sizeof(si)); - memset(&pi, 0, sizeof(pi)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; - si.hStdInput = hPipeRead; - si.hStdOutput = hNullOutput; - si.hStdError = hShareError; - - if (!CreateProcess(NULL, pCommand, NULL, NULL, - TRUE, /* Inherit handles */ - 0, /* Creation flags */ - NULL, NULL, - &si, &pi)) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Not able to create the child process."); - /* - * We must close the handles to the new process and its main thread - * to prevent handle and memory leaks. - */ - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(hPipeRead); - CloseHandle(hPipeWrite); - CloseHandle(hNullOutput); - - return -1; - } - else { - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, server_conf, - "Parent: Created child process %d", pi.dwProcessId); - - /* Assume the child process lives. Update the process and event tables */ - handles[*processes] = pi.hProcess; - events[*processes] = kill_event; - (*processes)++; - - /* We never store the thread's handle, so close it now. */ - CloseHandle(pi.hThread); - - /* Run the chain of open sockets. For each socket, duplicate it - * for the target process then send the WSAPROTOCOL_INFO - * (returned by dup socket) to the child */ - lr = ap_listeners; - while (lr != NULL) { - lpWSAProtocolInfo = ap_pcalloc(p, sizeof(WSAPROTOCOL_INFO)); - ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, server_conf, - "Parent: Duplicating socket %d and sending it to child process %d", lr->fd, pi.dwProcessId); - if (WSADuplicateSocket(lr->fd, - pi.dwProcessId, - lpWSAProtocolInfo) == SOCKET_ERROR) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: WSADuplicateSocket failed for socket %d.", lr->fd ); - return -1; - } - - if (!WriteFile(hPipeWrite, lpWSAProtocolInfo, (DWORD) sizeof(WSAPROTOCOL_INFO), - &BytesWritten, - (LPOVERLAPPED) NULL)) { - ap_log_error(APLOG_MARK, APLOG_WIN32ERROR | APLOG_CRIT, server_conf, - "Parent: Unable to write duplicated socket %d to the child.", lr->fd ); - return -1; - } - - lr = lr->next; - if (lr == ap_listeners) - break; - } - } - CloseHandle(hPipeRead); - CloseHandle(hPipeWrite); - CloseHandle(hNullOutput); - - return 0; -} - -/* To share the semaphores with other processes, we need a NULL ACL - * Code from MS KB Q106387 - */ - -static PSECURITY_ATTRIBUTES GetNullACL() -{ - PSECURITY_DESCRIPTOR pSD; - PSECURITY_ATTRIBUTES sa; - - sa = (PSECURITY_ATTRIBUTES) LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES)); - pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, - SECURITY_DESCRIPTOR_MIN_LENGTH); - if (pSD == NULL || sa == NULL) { - return NULL; - } - /* - * Win98 returns nonzero on failure; check LastError to make sure. - */ - SetLastError(0); - if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION) - || GetLastError()) { - LocalFree( pSD ); - LocalFree( sa ); - return NULL; - } - if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE) - || GetLastError()) { - LocalFree( pSD ); - LocalFree( sa ); - return NULL; - } - sa->nLength = sizeof(sa); - sa->lpSecurityDescriptor = pSD; - sa->bInheritHandle = TRUE; - return sa; -} - - -static void CleanNullACL( void *sa ) { - if( sa ) { - LocalFree( ((PSECURITY_ATTRIBUTES)sa)->lpSecurityDescriptor); - LocalFree( sa ); - } -} - -int master_main(int argc, char **argv) -{ - /* returns NULL if invalid (Win95?) */ - PSECURITY_ATTRIBUTES sa = GetNullACL(); - int nchild = ap_daemons_to_start; - int child_num = 0; - int rv, cld; - char signal_prefix_string[100]; - int i; - time_t tmstart; - HANDLE signal_shutdown_event; /* used to signal shutdown to parent */ - HANDLE signal_restart_event; /* used to signal a restart to parent */ - HANDLE process_handles[MAX_PROCESSES]; - HANDLE process_kill_events[MAX_PROCESSES]; - int current_live_processes = 0; /* number of child process we know about */ - int processes_to_create = 0; /* number of child processes to create */ - pool *pparent = NULL; /* pool for the parent process. Cleaned on each restart */ - - nchild = 1; /* only allowed one child process for current generation */ - processes_to_create = nchild; - - is_graceful = 0; - - ap_snprintf(signal_prefix_string, sizeof(signal_prefix_string), - "ap%d", getpid()); - setup_signal_names(signal_prefix_string); - - /* Create shutdown event, apPID_shutdown, where PID is the parent - * Apache process ID. Shutdown is signaled by 'apache -k shutdown'. - */ - signal_shutdown_event = CreateEvent(sa, TRUE, FALSE, signal_shutdown_name); - if (!signal_shutdown_event) { - ap_log_error(APLOG_MARK, APLOG_EMERG|APLOG_WIN32ERROR, server_conf, - "master_main: Cannot create shutdown event %s", signal_shutdown_name); - CleanNullACL((void *)sa); - exit(1); - } - - /* Create restart event, apPID_restart, where PID is the parent - * Apache process ID. Restart is signaled by 'apache -k restart'. - */ - signal_restart_event = CreateEvent(sa, TRUE, FALSE, signal_restart_name); - if (!signal_restart_event) { - CloseHandle(signal_shutdown_event); - ap_log_error(APLOG_MARK, APLOG_EMERG|APLOG_WIN32ERROR, server_conf, - "master_main: Cannot create restart event %s", signal_restart_name); - CleanNullACL((void *)sa); - exit(1); - } - CleanNullACL((void *)sa); - - /* Create the start mutex, apPID, where PID is the parent Apache process ID. - * Ths start mutex is used during a restart to prevent more than one - * child process from entering the accept loop at once. - */ - start_mutex = ap_create_mutex(signal_prefix_string); - restart_pending = shutdown_pending = 0; - - do { /* restart-pending */ - if (!is_graceful) { - ap_restart_time = time(NULL); - } - copy_listeners(pconf); - ap_clear_pool(pconf); - pparent = ap_make_sub_pool(pconf); - - server_conf = ap_read_config(pconf, pparent, ap_server_confname); - setup_listeners(pconf); - ap_clear_pool(plog); - ap_open_logs(server_conf, plog); - ap_set_version(); - ap_init_modules(pconf, server_conf); - version_locked++; - service_set_status(SERVICE_START_PENDING); - /* Create child processes */ - while (processes_to_create--) { - if (create_process(pconf, process_handles, process_kill_events, - ¤t_live_processes, &child_num, signal_prefix_string, argc, argv) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "master_main: create child process failed. Exiting."); - goto die_now; - } - } - service_set_status(SERVICE_RUNNING); - restart_pending = shutdown_pending = 0; - - /* Wait for either the shutdown or restart events to be signaled */ - process_handles[current_live_processes] = signal_shutdown_event; - process_handles[current_live_processes+1] = signal_restart_event; - rv = WaitForMultipleObjects(current_live_processes+2, (HANDLE *)process_handles, - FALSE, INFINITE); - if (rv == WAIT_FAILED) { - /* Something serious is wrong */ - ap_log_error(APLOG_MARK,APLOG_CRIT|APLOG_WIN32ERROR, server_conf, - "master_main: : WaitForMultipeObjects on process handles and apache-signal -- doing shutdown"); - shutdown_pending = 1; - break; - } - if (rv == WAIT_TIMEOUT) { - /* Hey, this cannot happen */ - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, - "master_main: WaitForMultipeObjects with INFINITE wait exited with WAIT_TIMEOUT"); - shutdown_pending = 1; - } - - cld = rv - WAIT_OBJECT_0; - APD4("main process: wait finished, cld=%d handle %d (max=%d)", cld, process_handles[cld], current_live_processes); - if (cld == current_live_processes) { - /* apPID_shutdown event signalled, we should exit now */ - shutdown_pending = 1; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, - "master_main: Shutdown event signaled. Shutting the server down."); - if (ResetEvent(signal_shutdown_event) == 0) { - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, server_conf, - "ResetEvent(signal_shutdown_event)"); - } - /* Signal each child processes to die */ - for (i = 0; i < current_live_processes; i++) { - APD3("master_main: signalling child %d, handle %d to die", i, process_handles[i]); - if (SetEvent(process_kill_events[i]) == 0) - ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_WIN32ERROR, server_conf, - "master_main: SetEvent for child process in slot #%d failed", i); - } - break; - } else if (cld == current_live_processes+1) { - /* apPID_restart event signalled. - * Signal the child to shutdown and start a new child process. - * The restart event can be signaled by a command line restart or - * by the child process when it handles MaxRequestPerChild connections. - */ - int children_to_kill = current_live_processes; - restart_pending = 1; - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, - "master_main: Restart event signaled. Doing a graceful restart."); - if (ResetEvent(signal_restart_event) == 0) { - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, server_conf, - "master_main: ResetEvent(signal_restart_event) failed."); - } - /* Signal each child process to die */ - for (i = 0; i < children_to_kill; i++) { - APD3("master_main: signalling child #%d handle %d to die", i, process_handles[i]); - if (SetEvent(process_kill_events[i]) == 0) - ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, server_conf, - "master_main: SetEvent for child process in slot #%d failed", i); - /* Remove the process (and event) from the process table */ - cleanup_process(process_handles, process_kill_events, i, ¤t_live_processes); - } - processes_to_create = 1; - ++ap_my_generation; - continue; - } else { - /* The child process exited premeturely because of a fatal error condition - * (eg, seg fault). Cleanup and restart the child process. - */ - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, - "master_main: Child processed exited prematurely. Restarting the child process."); - ap_assert(cld < current_live_processes); - cleanup_process(process_handles, process_kill_events, cld, ¤t_live_processes); - APD2("main_process: child in slot %d died", rv); - processes_to_create = 1; - continue; - } - - } while (1); - - /* If we dropped out of the loop we definitly want to die completely. We need to - * make sure we wait for all the child process to exit first. - */ - - APD2("*** main process shutdown, processes=%d ***", current_live_processes); - -die_now: - - tmstart = time(NULL); - while (current_live_processes && ((tmstart+60) > time(NULL))) { - service_set_status(SERVICE_STOP_PENDING); - rv = WaitForMultipleObjects(current_live_processes, (HANDLE *)process_handles, FALSE, 2000); - if (rv == WAIT_TIMEOUT) - continue; - ap_assert(rv != WAIT_FAILED); - cld = rv - WAIT_OBJECT_0; - ap_assert(rv < current_live_processes); - APD4("main_process: child in #%d handle %d died, left=%d", - rv, process_handles[rv], current_live_processes); - cleanup_process(process_handles, process_kill_events, cld, ¤t_live_processes); - } - for (i = 0; i < current_live_processes; i++) { - ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO, server_conf, - "forcing termination of child #%d (handle %d)", i, process_handles[i]); - TerminateProcess((HANDLE) process_handles[i], 1); - } - - CloseHandle(signal_restart_event); - CloseHandle(signal_shutdown_event); - - /* cleanup pid file on normal shutdown */ - { - const char *pidfile = NULL; - pidfile = ap_server_root_relative (pparent, ap_pid_fname); - if ( pidfile != NULL && unlink(pidfile) == 0) - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, - server_conf, - "removed PID file %s (pid=%u)", - pidfile, getpid()); - } - - if (pparent) { - ap_destroy_pool(pparent); - } - - ap_destroy_mutex(start_mutex); - return (0); -} - -/* - * Send signal to a running Apache. On entry signal should contain - * either "shutdown" or "restart" - */ - -int send_signal(pool *p, char *signal) -{ - char prefix[20]; - FILE *fp; - int nread; - char *fname; - int end; - - fname = ap_server_root_relative (p, ap_pid_fname); - - fp = fopen(fname, "r"); - if (!fp) { - printf("Cannot read apache PID file %s\n", fname); - return FALSE; - } - prefix[0] = 'a'; - prefix[1] = 'p'; - - nread = fread(prefix+2, 1, sizeof(prefix)-3, fp); - if (nread == 0) { - fclose(fp); - printf("PID file %s was empty\n", fname); - return FALSE; - } - fclose(fp); - - /* Terminate the prefix string */ - end = 2 + nread - 1; - while (end > 0 && (prefix[end] == '\r' || prefix[end] == '\n')) - end--; - prefix[end + 1] = '\0'; - - setup_signal_names(prefix); - - if (!strcasecmp(signal, "shutdown")) - ap_start_shutdown(); - else if (!strcasecmp(signal, "restart")) - ap_start_restart(1); - else { - printf("Unknown signal name \"%s\". Use either shutdown or restart.\n", - signal); - return FALSE; - } - return TRUE; -} - -void post_parse_init() -{ - ap_set_version(); - ap_init_modules(pconf, server_conf); - ap_suexec_enabled = init_suexec(); - version_locked++; - ap_open_logs(server_conf, plog); - set_group_privs(); -} - - -int REALMAIN(int argc, char *argv[]) -{ - int c; - int child = 0; - char *cp; - char *s; - int conf_specified = 0; - - - /* Console application or a child process. */ - - if ((s = strrchr(argv[0], PATHSEPARATOR)) != NULL) { - ap_server_argv0 = ++s; - } - else { - ap_server_argv0 = argv[0]; - } - - common_init(); - ap_setup_prelinked_modules(); - - /* initialize ap_server_root to the directory of the executable, in case - * the user chooses a relative path for the -d serverroot arg a bit later - */ - - - /* Fallback position if argv[0] wasn't deciphered - */ - if (!*ap_server_root) - ap_cpystrn(ap_server_root, HTTPD_ROOT, sizeof(ap_server_root)); - - chdir (ap_server_root); - - while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLesStTh")) != -1) { - char **new; - switch (c) { - case 'c': - new = (char **)ap_push_array(ap_server_post_read_config); - *new = ap_pstrdup(pcommands, optarg); - break; - case 'C': - new = (char **)ap_push_array(ap_server_pre_read_config); - *new = ap_pstrdup(pcommands, optarg); - break; - case 'D': - new = (char **)ap_push_array(ap_server_config_defines); - *new = ap_pstrdup(pcommands, optarg); - break; - case 'S': - ap_dump_settings = 1; - break; - case 'd': - optarg = ap_os_canonical_filename(pcommands, optarg); - if (!ap_os_is_path_absolute(optarg)) { - optarg = ap_pstrcat(pcommands, ap_server_root, "/", - optarg, NULL); - } - ap_cpystrn(ap_server_root, optarg, sizeof(ap_server_root)); - ap_getparents(ap_server_root); - ap_no2slash(ap_server_root); - if (ap_server_root[0] - && ap_server_root[strlen(ap_server_root) - 1] == '/') - ap_server_root[strlen(ap_server_root) - 1] = '\0'; - break; - case 'F': - do_detach = 0; - break; - case 'f': - ap_cpystrn(ap_server_confname, - ap_os_canonical_filename(pcommands, optarg), - sizeof(ap_server_confname)); - conf_specified = 1; - break; - case 'v': - ap_set_version(); - printf("Server version: %s\n", ap_get_server_version()); - printf("Server built: %s\n", ap_get_server_built()); - clean_parent_exit(0); - - case 'V': - ap_set_version(); - show_compile_settings(); - clean_parent_exit(0); - - case 'l': - ap_show_modules(); - clean_parent_exit(0); - - case 'L': - ap_show_directives(); - clean_parent_exit(0); - - case 'X': - ++one_process; /* Weird debugging mode. */ - break; - case 't': - ap_configtestonly = 1; - ap_docrootcheck = 1; - break; - case 'T': - ap_configtestonly = 1; - ap_docrootcheck = 0; - break; - case 'h': - usage(ap_server_argv0); - case '?': - usage(ap_server_argv0); - } /* switch */ - } /* while */ - - /* ServerRoot/ServerConfFile are found in this order: - * (1) serverroot set to Apache.exe's path, or HTTPD_ROOT if unparsable - * (2) arguments are grabbed for the -n named service, if given - * (3) the -d argument is taken from the given command line - * (4) the -d argument is taken from the service's default args - * (5) the -f argument is taken from the given command line - * (6) the -f argument is taken from the service's default args - * (7) if -f is omitted, then initialized to SERVER_CONFIG_FILE - * (8) if ap_server_confname is not absolute, then merge it to serverroot - */ - - if (!conf_specified) - ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname)); - -#ifdef EAPI - ap_init_alloc_shared(TRUE); -#endif - - if (!ap_os_is_path_absolute(ap_server_confname)) - ap_cpystrn(ap_server_confname, - ap_server_root_relative(pcommands, ap_server_confname), - sizeof(ap_server_confname)); - ap_getparents(ap_server_confname); - ap_no2slash(ap_server_confname); - - server_conf = ap_read_config(pconf, ptrans, ap_server_confname); -#ifdef EAPI - ap_init_alloc_shared(FALSE); -#endif - - if (ap_configtestonly) { - fprintf(stderr, "%s: Syntax OK\n", ap_server_root_relative(pcommands, ap_server_confname)); - clean_parent_exit(0); - } - - if (ap_dump_settings) { - clean_parent_exit(0); - } - - if (!child && !ap_dump_settings) { - ap_log_pid(pconf, ap_pid_fname); - } - - post_parse_init(); - - - if (one_process && !exit_event) - exit_event = create_event(0, 0, NULL); - if (one_process && !start_mutex) - start_mutex = ap_create_mutex(NULL); - - /* - * In the future, the main will spawn off a couple - * of children and monitor them. As soon as a child - * exits, it spawns off a new one - */ - if (child || one_process) { - if (!exit_event || !start_mutex) - exit(-1); - worker_main(); - ap_destroy_mutex(start_mutex); - destroy_event(exit_event); - } - else - { - master_main(argc, argv); - } - - clean_parent_exit(0); - return 0; /* purely to avoid a warning */ -} - -#endif /* ndef MULTITHREAD */ - -#else /* ndef SHARED_CORE_TIESTATIC */ - -/* -** Standalone Tie Program for Shared Core support -** -** It's purpose is to tie the static libraries and -** the shared core library under link-time and -** passing execution control to the real main function -** in the shared core library under run-time. -*/ - -extern int ap_main(int argc, char *argv[]); - -int main(int argc, char *argv[]) -{ - return ap_main(argc, argv); -} - -#endif /* ndef SHARED_CORE_TIESTATIC */ -#else /* ndef SHARED_CORE_BOOTSTRAP */ - - -/* -** Standalone Bootstrap Program for Shared Core support -** -** It's purpose is to initialise the LD_LIBRARY_PATH -** environment variable therewith the Unix loader is able -** to start the Standalone Tie Program (see above) -** and then replacing itself with this program by -** immediately passing execution to it. -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "ap_config.h" -#include "httpd.h" - -#define VARNAME "LD_LIBRARY_PATH" - -#ifndef SHARED_CORE_DIR -#define SHARED_CORE_DIR HTTPD_ROOT "/libexec" -#endif - -#ifndef SHARED_CORE_EXECUTABLE_PROGRAM -#define SHARED_CORE_EXECUTABLE_PROGRAM "lib" TARGET ".ep" -#endif - -extern char *optarg; -extern int optind; - -int main(int argc, char *argv[], char *envp[]) -{ - char prog[MAX_STRING_LEN]; - char llp_buf[MAX_STRING_LEN]; - char **llp_slot; - char *llp_existing; - char *llp_dir; - char **envpnew; - int c, i, l; - - - /* - * parse argument line, - * but only handle the -L option - */ - llp_dir = SHARED_CORE_DIR; - while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLR:SZ:tTh")) != -1) { - switch (c) { - case 'D': - case 'C': - case 'c': - case 'X': - case 'd': - case 'F': - case 'f': - case 'v': - case 'V': - case 'l': - case 'L': - case 'S': - case 'Z': - case 't': - case 'T': - case 'h': - case '?': - break; - case 'R': - llp_dir = strdup(optarg); - break; - } - } - - - /* - * create path to SHARED_CORE_EXECUTABLE_PROGRAM - */ - ap_snprintf(prog, sizeof(prog), "%s/%s", llp_dir, SHARED_CORE_EXECUTABLE_PROGRAM); - - /* - * adjust process environment therewith the Unix loader - * is able to start the SHARED_CORE_EXECUTABLE_PROGRAM. - */ - llp_slot = NULL; - llp_existing = NULL; - l = strlen(VARNAME); - for (i = 0; envp[i] != NULL; i++) { - if (strncmp(envp[i], VARNAME "=", l+1) == 0) { - llp_slot = &envp[i]; - llp_existing = strchr(envp[i], '=') + 1; - } - } - if (llp_slot == NULL) { - envpnew = (char **)malloc(sizeof(char *)*(i + 2)); - if (envpnew == NULL) { - fprintf(stderr, "Ouch! Out of memory generating envpnew!\n"); - } - memcpy(envpnew, envp, sizeof(char *)*i); - envp = envpnew; - llp_slot = &envp[i++]; - envp[i] = NULL; - } - if (llp_existing != NULL) - ap_snprintf(llp_buf, sizeof(llp_buf), "%s=%s:%s", VARNAME, llp_dir, llp_existing); - else - ap_snprintf(llp_buf, sizeof(llp_buf), "%s=%s", VARNAME, llp_dir); - *llp_slot = strdup(llp_buf); - - /* - * finally replace our process with - * the SHARED_CORE_EXECUTABLE_PROGRAM - */ - if (execve(prog, argv, envp) == -1) { - fprintf(stderr, - "%s: Unable to exec Shared Core Executable Program `%s'\n", - argv[0], prog); - return 1; - } - else - return 0; -} - -#endif /* ndef SHARED_CORE_BOOTSTRAP */ - -#ifndef SHARED_CORE_BOOTSTRAP #include "httpd.h" /* * Force ap_validate_password() into the image so that modules like @@ -6397,10 +3355,9 @@ void suck_in_ap_validate_password(void) { ap_validate_password("a", "b"); } -#endif /* force Expat to be linked into the server executable */ -#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP) +#if defined(USE_EXPAT) #include "xmlparse.h" const XML_LChar *suck_in_expat(void); const XML_LChar *suck_in_expat(void) diff --git a/usr.sbin/httpd/src/main/http_protocol.c b/usr.sbin/httpd/src/main/http_protocol.c index d995723c5a5..b44be2af73c 100644 --- a/usr.sbin/httpd/src/main/http_protocol.c +++ b/usr.sbin/httpd/src/main/http_protocol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: http_protocol.c,v 1.27 2004/12/02 19:42:47 henning Exp $ */ +/* $OpenBSD: http_protocol.c,v 1.28 2005/02/09 12:13:09 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 * @@ -980,9 +980,7 @@ static int read_request_line(request_rec *r) } } /* we've probably got something to do, ignore graceful restart requests */ -#ifdef SIGUSR1 signal(SIGUSR1, SIG_IGN); -#endif ap_bsetflag(conn->client, B_SAFEREAD, 0); @@ -1153,9 +1151,7 @@ API_EXPORT(request_rec *) ap_read_request(conn_rec *conn) r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */ r->the_request = NULL; -#ifdef EAPI r->ctx = ap_ctx_new(r->pool); -#endif /* EAPI */ /* Get the request... */ @@ -1309,9 +1305,7 @@ API_EXPORT(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r rnew->main = (request_rec *) r; -#ifdef EAPI rnew->ctx = r->ctx; -#endif /* EAPI */ } @@ -2344,11 +2338,8 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) /* Make fb unbuffered and non-blocking */ ap_bsetflag(fb, B_RD, 0); -#ifndef TPF_NO_NONSOCKET_SELECT ap_bnonblock(fb, B_RD); -#endif fd = ap_bfileno(fb, B_RD); -#ifdef CHECK_FD_SETSIZE if (fd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, "send body: filedescriptor (%u) larger than FD_SETSIZE (%u) " @@ -2356,21 +2347,11 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) "larger FD_SETSIZE", fd, FD_SETSIZE); return 0; } -#endif ap_soft_timeout("send body", r); FD_ZERO(&fds); while (!r->connection->aborted) { -#ifdef NDELAY_PIPE_RETURNS_ZERO - /* Contributed by dwd@bell-labs.com for UTS 2.1.2, where the fcntl */ - /* O_NDELAY flag causes read to return 0 when there's nothing */ - /* available when reading from a pipe. That makes it tricky */ - /* to detect end-of-file :-(. This stupid bug is even documented */ - /* in the read(2) man page where it says that everything but */ - /* pipes return -1 and EAGAIN. That makes it a feature, right? */ - int afterselect = 0; -#endif if ((length > 0) && (total_bytes_sent + IOBUFSIZE) > length) len = length - total_bytes_sent; else @@ -2378,13 +2359,8 @@ API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length) do { n = ap_bread(fb, buf, len); -#ifdef NDELAY_PIPE_RETURNS_ZERO - if ((n > 0) || (n == 0 && afterselect)) - break; -#else if (n >= 0) break; -#endif if (r->connection->aborted) break; if (n < 0 && errno != EAGAIN) @@ -2403,16 +2379,7 @@ 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 } while (!r->connection->aborted); if (n < 1 || r->connection->aborted) { diff --git a/usr.sbin/httpd/src/main/http_request.c b/usr.sbin/httpd/src/main/http_request.c index 20f4fa0b5df..6d159205213 100644 --- a/usr.sbin/httpd/src/main/http_request.c +++ b/usr.sbin/httpd/src/main/http_request.c @@ -174,48 +174,13 @@ static int get_path_info(request_rec *r) char *end = &path[strlen(path)]; char *last_cp = NULL; int rv; -#if defined(HAVE_DRIVE_LETTERS) || defined(HAVE_UNC_PATHS) - char bStripSlash=1; -#endif if (r->finfo.st_mode) { /* assume path_info already set */ return OK; } -#ifdef HAVE_DRIVE_LETTERS - /* If the directory is x:\, then we don't want to strip - * the trailing slash since x: is not a valid directory. - */ - if (strlen(path) == 3 && path[1] == ':' && path[2] == '/') - bStripSlash = 0; -#endif - -#ifdef HAVE_UNC_PATHS - /* If UNC name == //machine/share/, do not - * advance over the trailing slash. Any other - * UNC name is OK to strip the slash. - */ - cp = end; - if (strlen(path) > 2 && path[0] == '/' && path[1] == '/' && - path[2] != '/' && cp[-1] == '/') { - char *p; - int iCount=0; - p = path; - while (p = strchr(p,'/')) { - p++; - iCount++; - } - - if (iCount == 4) - bStripSlash = 0; - } -#endif - -#if defined(HAVE_DRIVE_LETTERS) || defined(HAVE_UNC_PATHS) - if (bStripSlash) -#endif /* Advance over trailing slashes ... NOT part of filename * if file is not a UNC name (Win32 only). */ @@ -268,7 +233,6 @@ static int get_path_info(request_rec *r) * even if they returned an error. */ r->finfo.st_mode = 0; -#if defined(ENOENT) && defined(ENOTDIR) if (errno == ENOENT || errno == ENOTDIR) { last_cp = cp; @@ -279,42 +243,16 @@ static int get_path_info(request_rec *r) --cp; } else { -#if defined(EACCES) if (errno == EACCES) ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "access to %s failed because search " "permissions are missing on a component " "of the path", r->uri); else -#endif ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "access to %s failed", r->uri); return HTTP_FORBIDDEN; } -#else -#error ENOENT || ENOTDIR not defined; please see the -#error comments at this line in the source for a workaround. - /* - * If ENOENT || ENOTDIR is not defined in one of the your OS's - * include files, Apache does not know how to check to see why the - * stat() of the index file failed; there are cases where it can fail - * even though the file exists. This means that it is possible for - * someone to get a directory listing of a directory even though - * there is an index (eg. index.html) file in it. If you do not have - * a problem with this, delete the above #error lines and start the - * compile again. If you need to do this, please submit a bug report - * from http://www.apache.org/bug_report.html letting us know that - * you needed to do this. Please be sure to include the operating - * system you are using. - */ - last_cp = cp; - - while (--cp > path && *cp != '/') - continue; - - while (cp > path && cp[-1] == '/') - --cp; -#endif /* ENOENT && ENOTDIR */ } return OK; } @@ -331,9 +269,6 @@ static int directory_walk(request_rec *r) int res; unsigned i, num_dirs; int j, test_filename_len; -#if defined(HAVE_UNC_PATHS) || defined(NETWARE) - unsigned iStart = 1; -#endif /* * Are we dealing with a file? If not, we can (hopefuly) safely assume we @@ -441,33 +376,9 @@ static int directory_walk(request_rec *r) */ test_dirname = ap_palloc(r->pool, test_filename_len + 2); -#if defined(HAVE_UNC_PATHS) - /* If the name is a UNC name, then do not perform any true file test - * against the machine name (start at //machine/share/) - * This is optimized to use the normal walk (skips the redundant '/' root) - */ - if (num_dirs > 3 && test_filename[0] == '/' && test_filename[1] == '/') - iStart = 4; -#endif - -#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) - /* Should match <Directory> sections starting from '/', not 'e:/' - * (for example). WIN32/OS2/NETWARE do not have a single root directory, - * they have one for each filesystem. Traditionally, Apache has treated - * <Directory /> permissions as the base for the whole server, and this - * tradition should probably be preserved. - * - * NOTE: MUST SYNC WITH ap_make_dirstr_prefix() CHANGE IN src/main/util.c - */ - if (test_filename[0] == '/') - i = 1; - else - i = 0; -#else /* Normal File Systems are rooted at / */ i = 1; -#endif /* def HAVE_DRIVE_LETTERS || NETWARE */ /* j keeps track of which section we're on, see core_reorder_directories */ j = 0; @@ -487,10 +398,6 @@ static int directory_walk(request_rec *r) * permissions appropriate to the *parent* directory... */ -#if defined(HAVE_UNC_PATHS) || defined(NETWARE) - /* Test only legal names against the real filesystem */ - if (i >= iStart) -#endif if ((res = check_symlinks(test_dirname, core_dir->opts))) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Symbolic link not allowed: %s", test_dirname); @@ -514,15 +421,7 @@ static int directory_walk(request_rec *r) if (entry_core->r || !ap_os_is_path_absolute(entry_dir) -#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) - /* To account for the top-level "/" directory when i == 0 - * XXX: I think the net test is wrong... may fail ap_os_is_path_absolute - */ - || (entry_core->d_components > 1 - && entry_core->d_components > i)) -#else || entry_core->d_components > i) -#endif /* def HAVE_DRIVE_LETTERS || NETWARE */ break; this_conf = NULL; @@ -541,24 +440,11 @@ static int directory_walk(request_rec *r) core_dir = (core_dir_config *) ap_get_module_config(per_dir_defaults, &core_module); } -#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) - /* So that other top-level directory sections (e.g. "e:/") aren't - * skipped when i == 0 - * XXX: I don't get you here, Tim... That's a level 1 section, but - * we are at level 0. Did you mean fast-forward to the next? - */ - else if (!i) - break; -#endif /* def HAVE_DRIVE_LETTERS || NETWARE */ } overrides_here = core_dir->override; /* If .htaccess files are enabled, check for one. */ -#if defined(HAVE_UNC_PATHS) || defined(NETWARE) - /* Test only legal names against the real filesystem */ - if (i >= iStart) -#endif if (overrides_here) { void *htaccess_conf = NULL; @@ -910,7 +796,6 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */ if (stat(rnew->filename, &rnew->finfo) < 0) { rnew->finfo.st_mode = 0; -#ifdef ENAMETOOLONG /* Special case for filenames which exceed the maximum limit * imposed by the operating system (~1024). These should * NOT be treated like "file not found", because there is @@ -926,7 +811,6 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file, rnew->status = HTTP_FORBIDDEN; return rnew; } -#endif } if ((res = check_safe_file(rnew))) { @@ -1378,10 +1262,8 @@ static request_rec *internal_internal_redirect(const char *new_uri, request_rec new->method = r->method; new->method_number = r->method_number; -#ifdef EAPI /* initialize context _BEFORE_ ap_parse_uri() call */ new->ctx = r->ctx; -#endif /* EAPI */ ap_parse_uri(new, new_uri); new->request_config = ap_create_request_config(r->pool); new->per_dir_config = r->server->lookup_defaults; diff --git a/usr.sbin/httpd/src/main/rfc1413.c b/usr.sbin/httpd/src/main/rfc1413.c index f53d9e5a461..7321b0d2b1c 100644 --- a/usr.sbin/httpd/src/main/rfc1413.c +++ b/usr.sbin/httpd/src/main/rfc1413.c @@ -99,17 +99,6 @@ int ap_rfc1413_timeout = RFC1413_TIMEOUT; /* Global so it can be changed */ - -#ifdef MULTITHREAD -#define RFC_USER_STATIC - -static int setsocktimeout (int sock, int timeout) -{ - /* XXX Needs to be implemented for non-winsock platforms */ - return 0; -} -#else /* MULTITHREAD */ - #define RFC_USER_STATIC static static JMP_BUF timebuf; @@ -118,7 +107,6 @@ static void ident_timeout(int sig) { ap_longjmp(timebuf, sig); } -#endif /* bind_connect - bind both ends of a socket */ /* Ambarish fix this. Very broken */ @@ -243,12 +231,6 @@ API_EXPORT(char *) ap_rfc1413(conn_rec *conn, server_rec *srv) /* * Set up a timer so we won't get stuck while waiting for the server. */ -#ifdef MULTITHREAD - if (setsocktimeout(sock, ap_rfc1413_timeout) == 0) { - if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user, srv) >= 0) - result = ap_pstrdup (conn->pool, user); - } -#else if (ap_setjmp(timebuf) == 0) { ap_set_callback_and_alarm(ident_timeout, ap_rfc1413_timeout); @@ -256,7 +238,6 @@ API_EXPORT(char *) ap_rfc1413(conn_rec *conn, server_rec *srv) result = user; } ap_set_callback_and_alarm(NULL, 0); -#endif ap_pclosesocket(conn->pool, sock); conn->remote_logname = result; diff --git a/usr.sbin/httpd/src/main/util.c b/usr.sbin/httpd/src/main/util.c index ec296c7b074..c9fd0f9f4c3 100644 --- a/usr.sbin/httpd/src/main/util.c +++ b/usr.sbin/httpd/src/main/util.c @@ -197,7 +197,6 @@ API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t sec) } /* What a pain in the ass. */ -#if defined(HAVE_GMTOFF) API_EXPORT(struct tm *) ap_get_gmtoff(int *tz) { time_t tt = time(NULL); @@ -207,25 +206,6 @@ API_EXPORT(struct tm *) ap_get_gmtoff(int *tz) *tz = (int) (t->tm_gmtoff / 60); return t; } -#else -API_EXPORT(struct tm *) ap_get_gmtoff(int *tz) -{ - time_t tt = time(NULL); - struct tm gmt; - struct tm *t; - int days, hours, minutes; - - /* Assume we are never more than 24 hours away. */ - gmt = *gmtime(&tt); /* remember gmtime/localtime return ptr to static */ - t = localtime(&tt); /* buffer... so be careful */ - days = t->tm_yday - gmt.tm_yday; - hours = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) - + t->tm_hour - gmt.tm_hour); - minutes = hours * 60 + t->tm_min - gmt.tm_min; - *tz = minutes; - return t; -} -#endif /* Roy owes Rob beer. */ /* Rob owes Roy dinner. */ @@ -526,12 +506,6 @@ API_EXPORT(void) ap_no2slash(char *name) s = d = name; -#ifdef HAVE_UNC_PATHS - /* Check for UNC names. Leave leading two slashes. */ - if (s[0] == '/' && s[1] == '/') - *d++ = *s++; -#endif - while (*s) { if ((*d++ = *s) == '/') { do { @@ -565,13 +539,6 @@ API_EXPORT(void) ap_no2slash(char *name) */ API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n) { -#if defined(HAVE_DRIVE_LETTERS) || defined(NETWARE) - if (!n) { - *d = '/'; - *++d = '\0'; - return (d); - } -#endif /* def HAVE_DRIVE_LETTERS || NETWARE */ for (;;) { *d = *s; if (*d == '\0') { @@ -877,11 +844,7 @@ API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name) return NULL; } -#ifdef FOPEN_REQUIRES_T - file = ap_pfopen(p, name, "rt"); -#else file = ap_pfopen(p, name, "r"); -#endif #ifdef DEBUG saved_errno = errno; ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL, @@ -1813,156 +1776,15 @@ API_EXPORT(int) ap_is_url(const char *u) API_EXPORT(int) ap_can_exec(const struct stat *finfo) { -#ifdef MULTIPLE_GROUPS - int cnt; -#endif if (ap_user_id == finfo->st_uid) if (finfo->st_mode & S_IXUSR) return 1; if (ap_group_id == finfo->st_gid) if (finfo->st_mode & S_IXGRP) return 1; -#ifdef MULTIPLE_GROUPS - for (cnt = 0; cnt < NGROUPS_MAX; cnt++) { - if (group_id_list[cnt] == finfo->st_gid) - if (finfo->st_mode & S_IXGRP) - return 1; - } -#endif return ((finfo->st_mode & S_IXOTH) != 0); } -#ifdef NEED_STRDUP -char *strdup(const char *str) -{ - char *sdup; - - if (!(sdup = (char *) malloc(strlen(str) + 1))) { - fprintf(stderr, "Ouch! Out of memory in our strdup()!\n"); - return NULL; - } - sdup = strlcpy(sdup, str, strlen(str) + 1); - - return sdup; -} -#endif - -/* The following two routines were donated for SVR4 by Andreas Vogel */ -#ifdef NEED_STRCASECMP -int strcasecmp(const char *a, const char *b) -{ - const char *p = a; - const char *q = b; - for (p = a, q = b; *p && *q; p++, q++) { - int diff = ap_tolower(*p) - ap_tolower(*q); - if (diff) - return diff; - } - if (*p) - return 1; /* p was longer than q */ - if (*q) - return -1; /* p was shorter than q */ - return 0; /* Exact match */ -} - -#endif - -#ifdef NEED_STRNCASECMP -int strncasecmp(const char *a, const char *b, int n) -{ - const char *p = a; - const char *q = b; - - for (p = a, q = b; /*NOTHING */ ; p++, q++) { - int diff; - if (p == a + n) - return 0; /* Match up to n characters */ - if (!(*p && *q)) - return *p - *q; - diff = ap_tolower(*p) - ap_tolower(*q); - if (diff) - return diff; - } - /*NOTREACHED */ -} -#endif - -/* The following routine was donated for UTS21 by dwd@bell-labs.com */ -#ifdef NEED_STRSTR -char *strstr(char *s1, char *s2) -{ - char *p1, *p2; - if (*s2 == '\0') { - /* an empty s2 */ - return(s1); - } - while((s1 = strchr(s1, *s2)) != NULL) { - /* found first character of s2, see if the rest matches */ - p1 = s1; - p2 = s2; - while (*++p1 == *++p2) { - if (*p1 == '\0') { - /* both strings ended together */ - return(s1); - } - } - if (*p2 == '\0') { - /* second string ended, a match */ - break; - } - /* didn't find a match here, try starting at next character in s1 */ - s1++; - } - return(s1); -} -#endif - -#ifdef NEED_INITGROUPS -int initgroups(const char *name, gid_t basegid) -{ - gid_t groups[NGROUPS_MAX]; - struct group *g; - int index = 0; - - setgrent(); - - groups[index++] = basegid; - - while (index < NGROUPS_MAX && ((g = getgrent()) != NULL)) - if (g->gr_gid != basegid) { - char **names; - - for (names = g->gr_mem; *names != NULL; ++names) - if (!strcmp(*names, name)) - groups[index++] = g->gr_gid; - } - - endgrent(); - - return setgroups(index, groups); -} -#endif /* def NEED_INITGROUPS */ - -#ifdef NEED_WAITPID -/* From ikluft@amdahl.com - * this is not ideal but it works for SVR3 variants - * Modified by dwd@bell-labs.com to call wait3 instead of wait because - * apache started to use the WNOHANG option. - */ -int waitpid(pid_t pid, int *statusp, int options) -{ - int tmp_pid; - if (kill(pid, 0) == -1) { - errno = ECHILD; - return -1; - } - while (((tmp_pid = wait3(statusp, options, 0)) != pid) && - (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1)) - ; - return tmp_pid; -} -#endif - API_EXPORT(int) ap_ind(const char *s, char c) { register int x; @@ -2178,26 +2000,6 @@ API_EXPORT(char *) ap_uuencode(pool *p, char *string) } -#ifdef NEED_STRERROR -char * - strerror(int err) -{ - - char *p; - extern char *const sys_errlist[]; - - p = sys_errlist[err]; - return (p); -} -#endif - -#if defined(NEED_DIFFTIME) -double difftime(time_t time1, time_t time0) -{ - return (time1 - time0); -} -#endif - /* we want to downcase the type/subtype for comparison purposes * but nothing else because ;parameter=foo values are case sensitive. * XXX: in truth we want to downcase parameter names... but really, diff --git a/usr.sbin/httpd/src/main/util_script.c b/usr.sbin/httpd/src/main/util_script.c index f06190fdb59..1b5d2a2758d 100644 --- a/usr.sbin/httpd/src/main/util_script.c +++ b/usr.sbin/httpd/src/main/util_script.c @@ -228,12 +228,10 @@ API_EXPORT(void) ap_add_common_vars(request_rec *r) * wide open to CGIs stealing passwords and people viewing them * in the environment with "ps -e". But, if you must... */ -#ifndef SECURITY_HOLE_PASS_AUTHORIZATION else if (!strcasecmp(hdrs[i].key, "Authorization") || !strcasecmp(hdrs[i].key, "Proxy-Authorization")) { continue; } -#endif else { ap_table_addn(e, http2env(r->pool, hdrs[i].key), hdrs[i].val); } @@ -678,31 +676,18 @@ API_EXPORT(int) ap_call_exec(request_rec *r, child_info *pinfo, char *argv0, */ r->server->error_log = stderr; -#ifdef RLIMIT_CPU if (conf->limit_cpu != NULL) { if ((setrlimit(RLIMIT_CPU, conf->limit_cpu)) != 0) { ap_log_error(APLOG_MARK, APLOG_ERR, r->server, "setrlimit: failed to set CPU usage limit"); } } -#endif -#ifdef RLIMIT_NPROC if (conf->limit_nproc != NULL) { if ((setrlimit(RLIMIT_NPROC, conf->limit_nproc)) != 0) { ap_log_error(APLOG_MARK, APLOG_ERR, r->server, "setrlimit: failed to set process limit"); } } -#endif -#if defined(RLIMIT_AS) - if (conf->limit_mem != NULL) { - if ((setrlimit(RLIMIT_AS, conf->limit_mem)) != 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "setrlimit(RLIMIT_AS): failed to set memory " - "usage limit"); - } - } -#elif defined(RLIMIT_DATA) if (conf->limit_mem != NULL) { if ((setrlimit(RLIMIT_DATA, conf->limit_mem)) != 0) { ap_log_error(APLOG_MARK, APLOG_ERR, r->server, @@ -710,16 +695,6 @@ API_EXPORT(int) ap_call_exec(request_rec *r, child_info *pinfo, char *argv0, "usage limit"); } } -#elif defined(RLIMIT_VMEM) - if (conf->limit_mem != NULL) { - if ((setrlimit(RLIMIT_VMEM, conf->limit_mem)) != 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, r->server, - "setrlimit(RLIMIT_VMEM): failed to set memory " - "usage limit"); - } - } -#endif - if (ap_suexec_enabled && ((r->server->server_uid != ap_user_id) || (r->server->server_gid != ap_group_id) diff --git a/usr.sbin/httpd/src/modules/experimental/mod_auth_digest.c b/usr.sbin/httpd/src/modules/experimental/mod_auth_digest.c index 7c368181734..c5d2d90bd11 100644 --- a/usr.sbin/httpd/src/modules/experimental/mod_auth_digest.c +++ b/usr.sbin/httpd/src/modules/experimental/mod_auth_digest.c @@ -145,10 +145,6 @@ #include "util_md5.h" #include "ap_sha1.h" -#ifdef HAVE_SHMEM_MM -#include "mm.h" -#endif /* HAVE_SHMEM_MM */ - /* struct to hold the configuration info */ @@ -240,23 +236,7 @@ static unsigned char secret[SECRET_LEN]; static int call_cnt = 0; -#ifdef HAVE_SHMEM_MM -/* opaque stuff */ - -static MM *opaque_mm; -static unsigned long *opaque_cntr; - -static MM *client_mm; - -static MM *otn_count_mm; -static time_t *otn_counter; /* one-time-nonce counter */ - -#define SHMEM_SIZE 1000 /* ~ 12 entries */ -#define NUM_BUCKETS 15UL - -#else /* HAVE_SHMEM_MM */ static void *client_mm = NULL; -#endif /* HAVE_SHMEM_MM */ module MODULE_VAR_EXPORT digest_auth_module; @@ -264,30 +244,6 @@ module MODULE_VAR_EXPORT digest_auth_module; * initialization code */ -#ifdef HAVE_SHMEM_MM -static void cleanup_tables(void *not_used) -{ - fprintf(stderr, "Digest: cleaning up shared memory\n"); - fflush(stderr); - - if (client_mm) { - mm_destroy(client_mm); - client_mm = NULL; - } - - if (opaque_mm) { - mm_destroy(opaque_mm); - opaque_mm = NULL; - } - - if (otn_count_mm) { - mm_destroy(otn_count_mm); - otn_count_mm = NULL; - } -} -#endif /* HAVE_SHMEM_MM */ - -#ifdef __OpenBSD__ static void initialize_secret(server_rec *s) { u_int32_t rnd = 0, i; @@ -304,147 +260,6 @@ static void initialize_secret(server_rec *s) ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, "Digest: done"); } -#elif defined(WIN32) -/* TODO: abstract out the random number generation. APR? */ -static void initialize_secret(server_rec *s) -{ - HCRYPTPROV hProv; - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, - "Digest: generating secret for digest authentication ..."); - if (!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,0)) { - ap_log_error(APLOG_MARK, APLOG_CRIT, s, - "Digest: Error acquiring context. Errno = %d", - GetLastError()); - exit(EXIT_FAILURE); - } - if (!CryptGenRandom(hProv,sizeof(secret),secret)) { - ap_log_error(APLOG_MARK, APLOG_CRIT, s, - "Digest: Error generating secret. Errno = %d", - GetLastError()); - exit(EXIT_FAILURE); - } - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, "Digest: done"); -} -#else -static void initialize_secret(server_rec *s) -{ -#ifdef DEV_RANDOM - int rnd; - ssize_t got; - size_t tot; -#else - extern int randbyte(void); /* from the truerand library */ - unsigned int idx; -#endif - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, - "Digest: generating secret for digest authentication ..."); - -#ifdef DEV_RANDOM -#define XSTR(x) #x -#define STR(x) XSTR(x) - if ((rnd = open(STR(DEV_RANDOM), O_RDONLY)) == -1) { - ap_log_error(APLOG_MARK, APLOG_CRIT, s, - "Digest: Couldn't open " STR(DEV_RANDOM)); - exit(EXIT_FAILURE); - } - for (tot=0; tot<sizeof(secret); tot += got) { - if ((got = read(rnd, secret+tot, sizeof(secret)-tot)) < 0) { - ap_log_error(APLOG_MARK, APLOG_CRIT, s, - "Digest: Error reading " STR(DEV_RANDOM)); - exit(EXIT_FAILURE); - } - } - close(rnd); -#undef STR -#undef XSTR -#else /* use truerand */ - /* this will increase the startup time of the server, unfortunately... - * (generating 20 bytes takes about 8 seconds) - */ - for (idx=0; idx<sizeof(secret); idx++) - secret[idx] = (unsigned char) randbyte(); -#endif /* DEV_RANDOM */ - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, "Digest: done"); -} -#endif - -#ifdef HAVE_SHMEM_MM -static void initialize_tables(server_rec *s) -{ - unsigned long idx; - - /* set up client list */ - - client_mm = mm_create(SHMEM_SIZE, tmpnam(NULL)); - if (client_mm == NULL) - goto failed; - if (geteuid() == 0) { - if (mm_permission(client_mm, 0600, ap_user_id, ap_group_id)) - goto failed; - } - client_list = mm_malloc(client_mm, sizeof(*client_list) + - sizeof(client_entry*)*NUM_BUCKETS); - if (!client_list) goto failed; - client_list->table = (client_entry**) (client_list + 1); - for (idx=0; idx<NUM_BUCKETS; idx++) - client_list->table[idx] = NULL; - client_list->tbl_len = NUM_BUCKETS; - client_list->num_entries = 0; - - - /* setup opaque */ - - opaque_mm = mm_create(sizeof(*opaque_cntr), tmpnam(NULL)); - if (opaque_mm == NULL) - goto failed; - if (geteuid() == 0) { - if (mm_permission(opaque_mm, 0600, ap_user_id, ap_group_id)) - goto failed; - } - opaque_cntr = mm_malloc(opaque_mm, sizeof(*opaque_cntr)); - if (opaque_cntr == NULL) - goto failed; - *opaque_cntr = 1UL; - - - /* setup one-time-nonce counter */ - - otn_count_mm = mm_create(sizeof(*otn_counter), tmpnam(NULL)); - if (otn_count_mm == NULL) - goto failed; - if (geteuid() == 0) { - if (mm_permission(otn_count_mm, 0600, ap_user_id, ap_group_id)) - goto failed; - } - otn_counter = mm_malloc(otn_count_mm, sizeof(*otn_counter)); - if (otn_counter == NULL) - goto failed; - *otn_counter = 0; - - - /* success */ - return; - -failed: - if (!client_mm || (client_list && client_list->table && !opaque_mm) - || (opaque_cntr && !otn_count_mm)) - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, s, - "Digest: failed to create shared memory segments; reason " - "was `%s' - all nonce-count checking, one-time nonces, " - "and MD5-sess algorithm disabled", mm_error()); - else - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, s, - "Digest: failed to allocate shared mem; reason was `%s' " - "- all nonce-count checking, one-time nonces, and " - "MD5-sess algorithm disabled", mm_error()); - - cleanup_tables(NULL); -} -#endif /* HAVE_SHMEM_MM */ static void initialize_module(server_rec *s, pool *p) { @@ -457,22 +272,6 @@ static void initialize_module(server_rec *s, pool *p) /* only initialize the secret on startup, not on restarts */ if (call_cnt == 2) initialize_secret(s); - -#ifdef HAVE_SHMEM_MM - /* Note: this stuff is currently fixed for the lifetime of the server, - * i.e. even across restarts. This means that A) any shmem-size - * configuration changes are ignored, and B) certain optimizations, - * such as only allocating the smallest necessary entry for each - * client, can't be done. However, the alternative is a nightmare: - * we can't call mm_destroy on a graceful restart because there will - * be children using the tables, and we also don't know when the - * last child dies. Therefore we can never clean up the old stuff, - * creating a creeping memory leak. - */ - initialize_tables(s); - /* atexit(cleanup_tables); */ - ap_register_cleanup(p, NULL, cleanup_tables, ap_null_cleanup); -#endif /* HAVE_SHMEM_MM */ } @@ -600,13 +399,9 @@ static const char *set_nc_check(cmd_parms *cmd, void *config, int flag) static const char *set_algorithm(cmd_parms *cmd, void *config, const char *alg) { if (!strcasecmp(alg, "MD5-sess")) -#ifdef HAVE_SHMEM_MM - ; -#else /* HAVE_SHMEM_MM */ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, cmd->server, "Digest: WARNING: algorithm `MD5-sess' is currently not " "correctly implemented"); -#endif /* HAVE_SHMEM_MM */ else if (strcasecmp(alg, "MD5")) return ap_pstrcat(cmd->pool, "Invalid algorithm in AuthDigestAlgorithm: ", alg, NULL); @@ -649,192 +444,10 @@ static const command_rec digest_cmds[] = {NULL, NULL, NULL, 0, 0, NULL} }; - -#ifdef HAVE_SHMEM_MM -/* - * client list code - * - * Each client is assigned a number, which is transferred in the opaque - * field of the WWW-Authenticate and Authorization headers. The number - * is just a simple counter which is incremented for each new client. - * Clients can't forge this number because it is hashed up into the - * server nonce, and that is checked. - * - * The clients are kept in a simple hash table, which consists of an - * array of client_entry's, each with a linked list of entries hanging - * off it. The client's number modulo the size of the array gives the - * bucket number. - * - * The clients are garbage collected whenever a new client is allocated - * but there is not enough space left in the shared memory segment. A - * simple semi-LRU is used for this: whenever a client entry is accessed - * it is moved to the beginning of the linked list in its bucket (this - * also makes for faster lookups for current clients). The garbage - * collecter then just removes the oldest entry (i.e. the one at the - * end of the list) in each bucket. - * - * The main advantages of the above scheme are that it's easy to implement - * and it keeps the hash table evenly balanced (i.e. same number of entries - * in each bucket). The major disadvantage is that you may be throwing - * entries out which are in active use. This is not tragic, as these - * clients will just be sent a new client id (opaque field) and nonce - * with a stale=true (i.e. it will just look like the nonce expired, - * thereby forcing an extra round trip). If the shared memory segment - * has enough headroom over the current client set size then this should - * not occur too often. - * - * To help tune the size of the shared memory segment (and see if the - * above algorithm is really sufficient) a set of counters is kept - * indicating the number of clients held, the number of garbage collected - * clients, and the number of erroneously purged clients. These are printed - * out at each garbage collection run. Note that access to the counters is - * not synchronized because they are just indicaters, and whether they are - * off by a few doesn't matter; and for the same reason no attempt is made - * to guarantee the num_renewed is correct in the face of clients spoofing - * the opaque field. - */ - -/* - * Get the client given its client number (the key). Returns the entry, - * or NULL if its not found. - * - * Access to the list itself is synchronized via locks. However, access - * to the entry returned by get_client() is NOT synchronized. This means - * that there are potentially problems if a client uses multiple, - * simultaneous connections to access url's within the same protection - * space. However, these problems are not new: when using multiple - * connections you have no guarantee of the order the requests are - * processed anyway, so you have problems with the nonce-count and - * one-time nonces anyway. - */ -static client_entry *get_client(unsigned long key, const request_rec *r) -{ - int bucket; - client_entry *entry, *prev = NULL; - - - if (!key || !client_mm) return NULL; - - bucket = key % client_list->tbl_len; - entry = client_list->table[bucket]; - - mm_lock(client_mm, MM_LOCK_RD); - - while(entry && key != entry->key) { - prev = entry; - entry = entry->next; - } - - if (entry && prev) { /* move entry to front of list */ - prev->next = entry->next; - entry->next = client_list->table[bucket]; - client_list->table[bucket] = entry; - } - - mm_unlock(client_mm); - - if (entry) - ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, r, - "get_client(): client %lu found", key); - else - ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, r, - "get_client(): client %lu not found", key); - - return entry; -} - - -/* A simple garbage-collecter to remove unused clients. It removes the - * last entry in each bucket and updates the counters. Returns the - * number of removed entries. - */ -static long gc(void) -{ - client_entry *entry, *prev; - unsigned long num_removed = 0, idx; - - /* garbage collect all last entries */ - - for (idx=0; idx<client_list->tbl_len; idx++) { - entry = client_list->table[idx]; - prev = NULL; - while (entry->next) { /* find last entry */ - prev = entry; - entry = entry->next; - } - if (prev) prev->next = NULL; /* cut list */ - else client_list->table[idx] = NULL; - if (entry) { /* remove entry */ - mm_free(client_mm, entry); - num_removed++; - } - } - - /* update counters and log */ - - client_list->num_entries -= num_removed; - client_list->num_removed += num_removed; - - return num_removed; -} - - -/* - * Add a new client to the list. Returns the entry if successful, NULL - * otherwise. This triggers the garbage collection if memory is low. - */ -static client_entry *add_client(unsigned long key, client_entry *info, - server_rec *s) -{ - int bucket; - client_entry *entry; - - - if (!key || !client_mm) return NULL; - - bucket = key % client_list->tbl_len; - entry = client_list->table[bucket]; - - mm_lock(client_mm, MM_LOCK_RW); - - /* try to allocate a new entry */ - - entry = mm_malloc(client_mm, sizeof(client_entry)); - if (!entry) { - long num_removed = gc(); - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, s, - "Digest: gc'd %ld client entries. Total new clients: " - "%ld; Total removed clients: %ld; Total renewed clients: " - "%ld", num_removed, - client_list->num_created - client_list->num_renewed, - client_list->num_removed, client_list->num_renewed); - entry = mm_malloc(client_mm, sizeof(client_entry)); - if (!entry) return NULL; /* give up */ - } - - /* now add the entry */ - - memcpy(entry, info, sizeof(client_entry)); - entry->key = key; - entry->next = client_list->table[bucket]; - client_list->table[bucket] = entry; - client_list->num_created++; - client_list->num_entries++; - - mm_unlock(client_mm); - - ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, s, - "allocated new client %lu", key); - - return entry; -} -#else /* HAVE_SHMEM_MM */ static client_entry *get_client(unsigned long key, const request_rec *r) { return NULL; } -#endif /* HAVE_SHMEM_MM */ - /* * Authorization header parser code @@ -1027,14 +640,7 @@ static const char *gen_nonce(pool *p, time_t now, const char *opaque, if (conf->nonce_lifetime != 0) t.time = now; else -#ifdef HAVE_SHMEM_MM - /* this counter is not synch'd, because it doesn't really matter - * if it counts exactly. - */ - t.time = (*otn_counter)++; -#else /* HAVE_SHMEM_MM */ t.time = 42; -#endif /* HAVE_SHMEM_MM */ ap_base64encode_binary(nonce, t.arr, sizeof(t.arr)); gen_nonce_hash(nonce+NONCE_TIME_LEN, nonce, opaque, server, conf); @@ -1046,34 +652,7 @@ static const char *gen_nonce(pool *p, time_t now, const char *opaque, * Opaque and hash-table management */ -#ifdef HAVE_SHMEM_MM -/* - * Generate a new client entry, add it to the list, and return the - * entry. Returns NULL if failed. - */ -static client_entry *gen_client(const request_rec *r) -{ - unsigned long op; - client_entry new_entry = { 0, NULL, 0, "", "" }, *entry; - - if (!opaque_mm) return 0; - - mm_lock(opaque_mm, MM_LOCK_RW); - op = (*opaque_cntr)++; - mm_unlock(opaque_mm); - - if (!(entry = add_client(op, &new_entry, r->server))) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, - "Digest: failed to allocate client entry - ignoring " - "client"); - return NULL; - } - - return entry; -} -#else /* HAVE_SHMEM_MM */ static client_entry *gen_client(const request_rec *r) { return NULL; } -#endif /* HAVE_SHMEM_MM */ @@ -1618,12 +1197,6 @@ static int authenticate_digest_user(request_rec *r) /* or '*' matches empty path in scheme://host */ && !(d_uri.path && !r_uri.path && resp->psd_request_uri->hostname && d_uri.path[0] == '*' && d_uri.path[1] == '\0')) -#if 0 - /* check that query matches */ - || (d_uri.query != r_uri.query - && (!d_uri.query || !r_uri.query - || strcmp(d_uri.query, r_uri.query))) -#endif ) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, "Digest: uri mismatch - <%s> does not match " @@ -1855,17 +1428,6 @@ static int digest_check_auth(request_rec *r) * Authorization-Info header code */ -#ifdef SEND_DIGEST -static const char *hdr(const table *tbl, const char *name) -{ - const char *val = ap_table_get(tbl, name); - if (val) - return val; - else - return ""; -} -#endif - static int add_auth_info(request_rec *r) { const digest_config_rec *conf = @@ -1885,37 +1447,6 @@ static int add_auth_info(request_rec *r) if (resp->message_qop == NULL) { /* old client, so calc rfc-2069 digest */ -#ifdef SEND_DIGEST - /* most of this totally bogus because the handlers don't set the - * headers until the final handler phase (I wonder why this phase - * is called fixup when there's almost nothing you can fix up...) - * - * Because it's basically impossible to get this right (e.g. the - * Content-length is never set yet when we get here, and we can't - * calc the entity hash) it's best to just leave this #def'd out. - */ - char *entity_info = - ap_md5(r->pool, - (unsigned char *) ap_pstrcat(r->pool, resp->raw_request_uri, - ":", - r->content_type ? r->content_type : ap_default_type(r), ":", - hdr(r->headers_out, "Content-Length"), ":", - r->content_encoding ? r->content_encoding : "", ":", - hdr(r->headers_out, "Last-Modified"), ":", - r->no_cache && !ap_table_get(r->headers_out, "Expires") ? - ap_gm_timestr_822(r->pool, r->request_time) : - hdr(r->headers_out, "Expires"), - NULL)); - digest = - ap_md5(r->pool, - (unsigned char *)ap_pstrcat(r->pool, conf->ha1, ":", - resp->nonce, ":", - r->method, ":", - ap_gm_timestr_822(r->pool, r->request_time), ":", - entity_info, ":", - ap_md5(r->pool, (unsigned char *) ""), /* H(entity) - TBD */ - NULL)); -#endif } diff --git a/usr.sbin/httpd/src/modules/extra/mod_define.c b/usr.sbin/httpd/src/modules/extra/mod_define.c index 0cb95a459d0..88fb3f3d299 100644 --- a/usr.sbin/httpd/src/modules/extra/mod_define.c +++ b/usr.sbin/httpd/src/modules/extra/mod_define.c @@ -42,9 +42,6 @@ #include "http_core.h" #include "http_log.h" -#ifndef EAPI -#error "This module requires the Extended API (EAPI) facilities." -#endif /* * The global table of defines diff --git a/usr.sbin/httpd/src/modules/proxy/mod_proxy.c b/usr.sbin/httpd/src/modules/proxy/mod_proxy.c index eacea5c51f0..fb43af97974 100644 --- a/usr.sbin/httpd/src/modules/proxy/mod_proxy.c +++ b/usr.sbin/httpd/src/modules/proxy/mod_proxy.c @@ -219,9 +219,7 @@ static int proxy_trans(request_rec *r) static int proxy_fixup(request_rec *r) { char *url, *p; -#ifdef EAPI int rc; -#endif /* EAPI */ if (r->proxyreq == NOT_PROXY || strncmp(r->filename, "proxy:", 6) != 0) return DECLINED; @@ -229,14 +227,12 @@ static int proxy_fixup(request_rec *r) url = &r->filename[6]; /* canonicalise each specific scheme */ -#ifdef EAPI if (ap_hook_use("ap::mod_proxy::canon", AP_HOOK_SIG3(int,ptr,ptr), AP_HOOK_DECLINE(DECLINED), &rc, r, url) && rc != DECLINED) return rc; else -#endif /* EAPI */ if (strncasecmp(url, "http:", 5) == 0) return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT); else if (strncasecmp(url, "ftp:", 4) == 0) @@ -252,13 +248,10 @@ static int proxy_fixup(request_rec *r) static void proxy_init(server_rec *r, pool *p) { ap_proxy_garbage_init(r, p); -#ifdef EAPI ap_hook_use("ap::mod_proxy::init", AP_HOOK_SIG3(void,ptr,ptr), AP_HOOK_ALL, r, p); -#endif } -#ifdef EAPI static void proxy_addmod(module *m) { /* export: ap_proxy_http_canon() as `ap::mod_proxy::http::canon' */ @@ -289,7 +282,6 @@ static void proxy_remmod(module *m) ap_hook_unregister("ap::mod_proxy::error", ap_proxyerror); return; } -#endif /* EAPI */ /* Send a redirection if the request contains a hostname which is not */ /* fully qualified, i.e. doesn't have a domain name appended. Some proxy */ @@ -421,14 +413,12 @@ static int proxy_handler(request_rec *r) * CONNECT is a special method that bypasses the normal proxy * code. */ -#ifdef EAPI if (!ap_hook_use("ap::mod_proxy::handler", AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr), AP_HOOK_DECLINE(DECLINED), &rc, r, cr, url, ents[i].hostname, ents[i].port, ents[i].protocol) || rc == DECLINED) { -#endif /* EAPI */ if (r->method_number == M_CONNECT) rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname, ents[i].port); @@ -438,9 +428,7 @@ static int proxy_handler(request_rec *r) ents[i].port); else rc = DECLINED; -#ifdef EAPI } -#endif /* EAPI */ /* an error or success */ if (rc != DECLINED && rc != HTTP_BAD_GATEWAY) @@ -455,14 +443,12 @@ static int proxy_handler(request_rec *r) */ /* handle the scheme */ -#ifdef EAPI if (ap_hook_use("ap::mod_proxy::handler", AP_HOOK_SIG7(int,ptr,ptr,ptr,ptr,int,ptr), AP_HOOK_DECLINE(DECLINED), &rc, r, cr, url, NULL, 0, scheme) && rc != DECLINED) return rc; -#endif /* EAPI */ if (r->method_number == M_CONNECT) { return ap_proxy_connect_handler(r, cr, url, NULL, 0); } @@ -1061,10 +1047,8 @@ module MODULE_VAR_EXPORT proxy_module = NULL, /* child_init */ NULL, /* child_exit */ proxy_detect /* post read-request */ -#ifdef EAPI ,proxy_addmod, /* EAPI: add_module */ proxy_remmod, /* EAPI: remove_module */ NULL, /* EAPI: rewrite_command */ NULL /* EAPI: new_connection */ -#endif }; diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_cache.c b/usr.sbin/httpd/src/modules/proxy/proxy_cache.c index 39da529027f..04d1d66b44f 100644 --- a/usr.sbin/httpd/src/modules/proxy/proxy_cache.c +++ b/usr.sbin/httpd/src/modules/proxy/proxy_cache.c @@ -192,10 +192,6 @@ static void detached_proxy_garbage_coll(request_rec *r) int status; pid_t pgrp; -#if 0 - ap_log_error(APLOG_MARK, APLOG_DEBUG, r->server, - "proxy: Guess what; we fork() again..."); -#endif switch (pid = fork()) { case -1: ap_log_error(APLOG_MARK, APLOG_ERR, r->server, @@ -216,21 +212,12 @@ static void detached_proxy_garbage_coll(request_rec *r) case 0: /* Child */ /* The setpgrp() stuff was snarfed from http_main.c */ -#ifndef NO_SETSID if ((pgrp = setsid()) == -1) { perror("setsid"); fprintf(stderr, "%s: setsid failed\n", ap_server_argv0); exit(1); } -#else - if ((pgrp = setpgrp(getpid(), 0)) == -1) { - perror("setpgrp"); - fprintf(stderr, "%s: setpgrp failed\n", - ap_server_argv0); - exit(1); - } -#endif help_proxy_garbage_coll(r); exit(0); @@ -436,14 +423,11 @@ static int sub_garbage_coll(request_rec *r, array_header *files, continue; } ++nfiles; -/* is it another file? */ + /* is it another file? */ /* FIXME: Shouldn't any unexpected files be deleted? */ /* if (strlen(ent->d_name) != HASH_LEN) continue; */ -/* under OS/2 use dirent's d_attr to identify a diretory */ -/* under TPF use stat to identify a directory */ - -/* read the file */ + /* read the file */ fd = open(filename, O_RDONLY | O_BINARY); if (fd == -1) { if (errno != ENOENT) @@ -1230,9 +1214,6 @@ int ap_proxy_cache_check(request_rec *r, char *url, struct cache_conf * conf, int ap_proxy_cache_update(cache_req *c, table *resp_hdrs, const int is_HTTP1, int nocache) { -#if defined(ULTRIX_BRAIN_DEATH) || defined(SINIX_D_RESOLVER_BUG) - extern char *mktemp(char *template); -#endif request_rec *r = c->req; char *p; const char *expire, *lmods, *dates, *clen; diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_connect.c b/usr.sbin/httpd/src/modules/proxy/proxy_connect.c index 775c829e092..6e802651bbf 100644 --- a/usr.sbin/httpd/src/modules/proxy/proxy_connect.c +++ b/usr.sbin/httpd/src/modules/proxy/proxy_connect.c @@ -62,10 +62,6 @@ #include "http_log.h" #include "http_main.h" -#ifdef HAVE_BSTRING_H -#include <bstring.h> /* for IRIX, FD_SET calls bzero() */ -#endif - /* * This handles Netscape CONNECT method secure proxy requests. * A connection is opened to the specified host and data is @@ -188,7 +184,6 @@ int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url, return HTTP_INTERNAL_SERVER_ERROR; } -#ifdef CHECK_FD_SETSIZE if (sock >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_WARNING, NULL, "proxy_connect_handler: filedescriptor (%u) " @@ -198,7 +193,6 @@ int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url, ap_pclosesocket(r->pool, sock); return HTTP_INTERNAL_SERVER_ERROR; } -#endif j = 0; while (server_hp.h_addr_list[j] != NULL) { diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_ftp.c b/usr.sbin/httpd/src/modules/proxy/proxy_ftp.c index 5d92443e5a9..cbd976ac131 100644 --- a/usr.sbin/httpd/src/modules/proxy/proxy_ftp.c +++ b/usr.sbin/httpd/src/modules/proxy/proxy_ftp.c @@ -708,18 +708,6 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url) return HTTP_INTERNAL_SERVER_ERROR; } -#ifdef SINIX_D_RESOLVER_BUG - { - struct in_addr *ip_addr = (struct in_addr *)*server_hp.h_addr_list; - - for (; ip_addr->s_addr != 0; ++ip_addr) { - memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr)); - i = ap_proxy_doconnect(sock, &server, r); - if (i == 0) - break; - } - } -#else j = 0; while (server_hp.h_addr_list[j] != NULL) { memcpy(&server.sin_addr, server_hp.h_addr_list[j], @@ -729,7 +717,6 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url) break; j++; } -#endif if (i == -1) { return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool, @@ -757,24 +744,6 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url) ap_proxyerror(r, HTTP_BAD_GATEWAY, "Error reading from remote server")); } -#if 0 - if (i == 120) { - /* - * RFC2068 states: 14.38 Retry-After - * - * The Retry-After response-header field can be used with a 503 (Service - * Unavailable) response to indicate how long the service is expected - * to be unavailable to the requesting client. The value of this - * field can be either an HTTP-date or an integer number of seconds - * (in decimal) after the time of the response. Retry-After = - * "Retry-After" ":" ( HTTP-date | delta-seconds ) - */ -/**INDENT** Error@756: Unbalanced parens */ - ap_set_header("Retry-After", ap_psprintf(p, "%u", 60 * wait_mins); - return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, - ap_proxyerror(r, HTTP_SERVICE_UNAVAILABLE, resp)); - } -#endif if (i != 220) { return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, ap_proxyerror(r, HTTP_BAD_GATEWAY, resp)); diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_http.c b/usr.sbin/httpd/src/modules/proxy/proxy_http.c index 8530abba4e5..c750f5f78be 100644 --- a/usr.sbin/httpd/src/modules/proxy/proxy_http.c +++ b/usr.sbin/httpd/src/modules/proxy/proxy_http.c @@ -170,9 +170,7 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, const char *datestr, *urlstr; int result, major, minor; const char *content_length; -#ifdef EAPI char *peer; -#endif void *sconf = r->server->module_config; proxy_server_conf *conf = @@ -194,12 +192,10 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, return HTTP_BAD_REQUEST; urlptr += 3; destport = DEFAULT_HTTP_PORT; -#ifdef EAPI ap_hook_use("ap::mod_proxy::http::handler::set_destport", AP_HOOK_SIG2(int,ptr), AP_HOOK_TOPMOST, &destport, r); -#endif /* EAPI */ strp = strchr(urlptr, '/'); if (strp == NULL) { desthost = ap_pstrdup(p, urlptr); @@ -237,18 +233,14 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, err = ap_proxy_host2addr(proxyhost, &server_hp); if (err != NULL) return DECLINED; /* try another */ -#ifdef EAPI peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); -#endif } else { server.sin_port = htons((unsigned short)destport); err = ap_proxy_host2addr(desthost, &server_hp); if (err != NULL) return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err); -#ifdef EAPI peer = ap_psprintf(p, "%s:%u", desthost, destport); -#endif } @@ -272,18 +264,6 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, } } -#ifdef SINIX_D_RESOLVER_BUG - { - struct in_addr *ip_addr = (struct in_addr *)*server_hp.h_addr_list; - - for (; ip_addr->s_addr != 0; ++ip_addr) { - memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr)); - i = ap_proxy_doconnect(sock, &server, r); - if (i == 0) - break; - } - } -#else j = 0; while (server_hp.h_addr_list[j] != NULL) { memcpy(&server.sin_addr, server_hp.h_addr_list[j], @@ -293,7 +273,6 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, break; j++; } -#endif if (i == -1) { if (proxyhost != NULL) return DECLINED; /* try again another way */ @@ -321,7 +300,6 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, f = ap_bcreate(p, B_RDWR | B_SOCKET); ap_bpushfd(f, sock, sock); -#ifdef EAPI { char *errmsg = NULL; ap_hook_use("ap::mod_proxy::http::handler::new_connection", @@ -331,12 +309,10 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, if (errmsg != NULL) return ap_proxyerror(r, HTTP_BAD_GATEWAY, errmsg); } -#endif /* EAPI */ ap_hard_timeout("proxy send", r); ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.1" CRLF, NULL); -#ifdef EAPI { int rc = DECLINED; ap_hook_use("ap::mod_proxy::http::handler::write_host_header", @@ -350,13 +326,6 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, ap_bvputs(f, "Host: ", desthost, CRLF, NULL); } } -#else /* EAPI */ - /* Send Host: now, adding it to req_hdrs wouldn't be much better */ - if (destportstr != NULL && destport != DEFAULT_HTTP_PORT) - ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL); - else - ap_bvputs(f, "Host: ", desthost, CRLF, NULL); -#endif /* EAPI */ if (conf->viaopt == via_block) { /* Block all outgoing Via: headers */ diff --git a/usr.sbin/httpd/src/modules/proxy/proxy_util.c b/usr.sbin/httpd/src/modules/proxy/proxy_util.c index f902f2858e5..a246f0e9f7c 100644 --- a/usr.sbin/httpd/src/modules/proxy/proxy_util.c +++ b/usr.sbin/httpd/src/modules/proxy/proxy_util.c @@ -753,59 +753,6 @@ int ap_proxy_liststr(const char *list, const char *key, char **val) return 0; } -#ifdef CASE_BLIND_FILESYSTEM - -/* - * On some platforms, the file system is NOT case sensitive. So, a == A - * need to map to smaller set of characters - */ -void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength) -{ - AP_MD5_CTX context; - unsigned char digest[16]; - char tmp[26]; - int i, k, d; - unsigned int x; - static const char enc_table[32] = "abcdefghijklmnopqrstuvwxyz012345"; - - ap_MD5Init(&context); - ap_MD5Update(&context, (const unsigned char *)it, strlen(it)); - ap_MD5Final(digest, &context); - -/* encode 128 bits as 26 characters, using a modified uuencoding */ -/* the encoding is 5 bytes -> 8 characters - * i.e. 128 bits is 3 x 5 bytes + 1 byte -> 3 * 8 characters + 2 characters - */ - for (i = 0, k = 0; i < 15; i += 5) { - x = (digest[i] << 24) | (digest[i + 1] << 16) | (digest[i + 2] << 8) | digest[i + 3]; - tmp[k++] = enc_table[x >> 27]; - tmp[k++] = enc_table[(x >> 22) & 0x1f]; - tmp[k++] = enc_table[(x >> 17) & 0x1f]; - tmp[k++] = enc_table[(x >> 12) & 0x1f]; - tmp[k++] = enc_table[(x >> 7) & 0x1f]; - tmp[k++] = enc_table[(x >> 2) & 0x1f]; - x = ((x & 0x3) << 8) | digest[i + 4]; - tmp[k++] = enc_table[x >> 5]; - tmp[k++] = enc_table[x & 0x1f]; - } -/* one byte left */ - x = digest[15]; - tmp[k++] = enc_table[x >> 3]; /* use up 5 bits */ - tmp[k++] = enc_table[x & 0x7]; - /* now split into directory levels */ - - for (i = k = d = 0; d < ndepth; ++d) { - memcpy(&val[i], &tmp[k], nlength); - k += nlength; - val[i + nlength] = '/'; - i += nlength + 1; - } - memcpy(&val[i], &tmp[k], 26 - k); - val[i + 26 - k] = '\0'; -} - -#else - void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength) { AP_MD5_CTX context; @@ -847,8 +794,6 @@ void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength) val[i + 22 - k] = '\0'; } -#endif /* CASE_BLIND_FILESYSTEM */ - /* * Converts 16 hex digits to a time integer */ @@ -1207,13 +1152,6 @@ int ap_proxy_is_domainname(struct dirconn_entry *This, pool *p) for (i = 0; ap_isalnum(addr[i]) || addr[i] == '-' || addr[i] == '.'; ++i) continue; -#if 0 - if (addr[i] == ':') { - fprintf(stderr, "@@@@ handle optional port in proxy_is_domainname()\n"); - /* @@@@ handle optional port */ - } -#endif - if (addr[i] != '\0') return 0; @@ -1260,13 +1198,6 @@ int ap_proxy_is_hostname(struct dirconn_entry *This, pool *p) /* rfc1035 says DNS names must consist of "[-a-zA-Z0-9]" and '.' */ for (i = 0; ap_isalnum(addr[i]) || addr[i] == '-' || addr[i] == '.'; ++i); -#if 0 - if (addr[i] == ':') { - fprintf(stderr, "@@@@ handle optional port in proxy_is_hostname()\n"); - /* @@@@ handle optional port */ - } -#endif - if (addr[i] != '\0' || ap_proxy_host2addr(addr, &host) != NULL) return 0; @@ -1294,15 +1225,6 @@ static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r) h2_len = strlen(host2); h1_len = strlen(host); -#if 0 - unsigned long *ip_list; - - /* Try to deal with multiple IP addr's for a host */ - for (ip_list = *This->hostentry->h_addr_list; *ip_list != 0UL; ++ip_list) - if (*ip_list == ? ? ? ? ? ? ? ? ? ? ? ? ?) - return 1; -#endif - /* Ignore trailing dots in host2 comparison: */ while (h2_len > 0 && host2[h2_len - 1] == '.') --h2_len; diff --git a/usr.sbin/httpd/src/modules/ssl/ssl_engine_init.c b/usr.sbin/httpd/src/modules/ssl/ssl_engine_init.c index 863b7c4a01a..0d6227a9528 100644 --- a/usr.sbin/httpd/src/modules/ssl/ssl_engine_init.c +++ b/usr.sbin/httpd/src/modules/ssl/ssl_engine_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_engine_init.c,v 1.26 2004/12/06 13:14:10 henning Exp $ */ +/* $OpenBSD: ssl_engine_init.c,v 1.27 2005/02/09 12:13:10 henning Exp $ */ /* _ _ ** _ __ ___ ___ __| | ___ ___| | mod_ssl @@ -608,9 +608,7 @@ void ssl_init_ConfigureServer(server_rec *s, pool *p, SSLSrvConfigRec *sc) * Disallow a session from being resumed during a renegotiation, * so that an acceptable cipher suite can be negotiated. */ -#ifdef SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION SSL_CTX_set_options(ctx, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); -#endif /* * Configure callbacks for SSL context diff --git a/usr.sbin/httpd/src/modules/ssl/ssl_util.c b/usr.sbin/httpd/src/modules/ssl/ssl_util.c index 30cdedf70b0..7a87dfe38bb 100644 --- a/usr.sbin/httpd/src/modules/ssl/ssl_util.c +++ b/usr.sbin/httpd/src/modules/ssl/ssl_util.c @@ -176,9 +176,7 @@ int ssl_util_ppopen_child(void *cmd, child_info *pinfo) * Prepare for exec */ ap_cleanup_for_exec(); -#ifdef SIGHUP signal(SIGHUP, SIG_IGN); -#endif /* * Exec() the child program diff --git a/usr.sbin/httpd/src/modules/standard/mod_auth_dbm.c b/usr.sbin/httpd/src/modules/standard/mod_auth_dbm.c index 446dc2b6117..2f85f8e442d 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_auth_dbm.c +++ b/usr.sbin/httpd/src/modules/standard/mod_auth_dbm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mod_auth_dbm.c,v 1.12 2004/12/02 19:42:47 henning Exp $ */ +/* $OpenBSD: mod_auth_dbm.c,v 1.13 2005/02/09 12:13:10 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -150,11 +150,7 @@ static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile) char *pw = NULL; q.dptr = user; -#ifndef NETSCAPE_DBM_COMPAT q.dsize = strlen(q.dptr); -#else - q.dsize = strlen(q.dptr) + 1; -#endif ap_server_strip_chroot(auth_dbmpwfile, 1); diff --git a/usr.sbin/httpd/src/modules/standard/mod_autoindex.c b/usr.sbin/httpd/src/modules/standard/mod_autoindex.c index c3150296718..ab0932f1830 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_autoindex.c +++ b/usr.sbin/httpd/src/modules/standard/mod_autoindex.c @@ -291,11 +291,7 @@ static const char *add_icon(cmd_parms *cmd, void *d, char *icon, char *to) * Absent a strcasestr() function, we have to force wildcards on * systems for which "AAA" and "aaa" mean the same file. */ -#ifdef CASE_BLIND_FILESYSTEM -#define WILDCARDS_REQUIRED 1 -#else #define WILDCARDS_REQUIRED 0 -#endif static const char *add_desc(cmd_parms *cmd, void *d, char *desc, char *to) { @@ -814,11 +810,7 @@ static char *find_default_icon(autoindex_config_rec *d, char *bogus_name) * directives will dominate. */ -#ifdef CASE_BLIND_FILESYSTEM -#define MATCH_FLAGS FNM_CASE_BLIND -#else #define MATCH_FLAGS 0 -#endif static char *find_desc(autoindex_config_rec *dcfg, request_rec *r) { @@ -888,22 +880,10 @@ static int ignore_entry(autoindex_config_rec *d, char *path) ap++; } -#ifndef CASE_BLIND_FILESYSTEM if (!ap_strcmp_match(path, p->apply_path) && !ap_strcmp_match(tt, ap)) { return 1; } -#else /* !CASE_BLIND_FILESYSTEM */ - /* - * On some platforms, the match must be case-blind. This is really - * a factor of the filesystem involved, but we can't detect that - * reliably - so we have to granularise at the OS level. - */ - if (!ap_strcasecmp_match(path, p->apply_path) - && !ap_strcasecmp_match(tt, ap)) { - return 1; - } -#endif /* !CASE_BLIND_FILESYSTEM */ } return 0; } diff --git a/usr.sbin/httpd/src/modules/standard/mod_include.c b/usr.sbin/httpd/src/modules/standard/mod_include.c index 4b02a7cc398..75518f5ff06 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_include.c +++ b/usr.sbin/httpd/src/modules/standard/mod_include.c @@ -632,10 +632,6 @@ static int include_cgi(char *s, request_rec *r) */ static int is_only_below(const char *path) { -#ifdef HAVE_DRIVE_LETTERS - if (path[1] == ':') - return 0; -#endif if (path[0] == '/') { return 0; } diff --git a/usr.sbin/httpd/src/modules/standard/mod_log_config.c b/usr.sbin/httpd/src/modules/standard/mod_log_config.c index 055e3257269..7d57734092e 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_log_config.c +++ b/usr.sbin/httpd/src/modules/standard/mod_log_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mod_log_config.c,v 1.16 2004/12/02 19:42:48 henning Exp $ */ +/* $OpenBSD: mod_log_config.c,v 1.17 2005/02/09 12:13:10 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -261,9 +261,7 @@ typedef struct { typedef const char *(*item_key_func) (request_rec *, char *); typedef struct { -#ifdef EAPI char ch; -#endif item_key_func func; char *arg; int condition_sense; @@ -582,23 +580,16 @@ static struct log_item_list { } }; -#ifdef EAPI static struct log_item_list *find_log_func(pool *p, char k) -#else /* EAPI */ -static struct log_item_list *find_log_func(char k) -#endif /* EAPI */ { int i; -#ifdef EAPI struct log_item_list *lil; -#endif /* EAPI */ for (i = 0; log_item_keys[i].ch; ++i) if (k == log_item_keys[i].ch) { return &log_item_keys[i]; } -#ifdef EAPI if (ap_hook_status(ap_psprintf(p, "ap::mod_log_config::log_%c", k)) != AP_HOOK_STATE_NOTEXISTANT) { lil = (struct log_item_list *) @@ -610,7 +601,6 @@ static struct log_item_list *find_log_func(char k) lil->want_orig_default = 0; return lil; } -#endif /* EAPI */ return NULL; } @@ -737,11 +727,7 @@ static char *parse_log_item(pool *p, log_format_item *it, const char **sa) break; default: -#ifdef EAPI l = find_log_func(p, *s++); -#else /* EAPI */ - l = find_log_func(*s++); -#endif /* EAPI */ if (!l) { char dummy[2]; @@ -750,9 +736,7 @@ static char *parse_log_item(pool *p, log_format_item *it, const char **sa) return ap_pstrcat(p, "Unrecognized LogFormat directive %", dummy, NULL); } -#ifdef EAPI it->ch = s[-1]; -#endif it->func = l->func; if (it->want_orig == -1) { it->want_orig = l->want_orig_default; @@ -814,7 +798,6 @@ static const char *process_item(request_rec *r, request_rec *orig, /* We do. Do it... */ -#ifdef EAPI if (item->func == NULL) { cp = NULL; ap_hook_use(ap_psprintf(r->pool, "ap::mod_log_config::log_%c", item->ch), @@ -822,7 +805,6 @@ static const char *process_item(request_rec *r, request_rec *orig, &cp, r, item->arg); } else -#endif cp = (*item->func) (item->want_orig ? orig : r, item->arg); return cp ? cp : "-"; } diff --git a/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c b/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c index 8e676444e02..a9b6ddf5636 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c +++ b/usr.sbin/httpd/src/modules/standard/mod_mime_magic.c @@ -381,33 +381,6 @@ static struct names { { ".PRECIOUS", L_MAKE }, - /* - * Too many files of text have these words in them. Find another way to - * recognize Fortrash. - */ -#ifdef NOTDEF - { - "subroutine", L_FORT - }, - { - "function", L_FORT - }, - { - "block", L_FORT - }, - { - "common", L_FORT - }, - { - "dimension", L_FORT - }, - { - "integer", L_FORT - }, - { - "data", L_FORT - }, -#endif /* NOTDEF */ { ".ascii", L_MACH }, @@ -1458,7 +1431,6 @@ static int fsmagic(request_rec *r, const char *fn) */ (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN); return DONE; -#ifdef S_IFBLK case S_IFBLK: /* * (void) magic_rsl_printf(r,"block special (%d/%d)", @@ -1467,16 +1439,12 @@ static int fsmagic(request_rec *r, const char *fn) (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN); return DONE; /* TODO add code to handle V7 MUX and Blit MUX files */ -#endif -#ifdef S_IFIFO case S_IFIFO: /* * magic_rsl_puts(r,"fifo (named pipe)"); */ (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN); return DONE; -#endif -#ifdef S_IFLNK case S_IFLNK: /* We used stat(), the only possible reason for this is that the * symlink is broken. @@ -1484,14 +1452,9 @@ static int fsmagic(request_rec *r, const char *fn) ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r, MODNAME ": broken symlink (%s)", fn); return HTTP_INTERNAL_SERVER_ERROR; -#endif -#ifdef S_IFSOCK -#ifndef __COHERENT__ case S_IFSOCK: magic_rsl_puts(r, MIME_BINARY_UNKNOWN); return DONE; -#endif -#endif case S_IFREG: break; default: diff --git a/usr.sbin/httpd/src/modules/standard/mod_negotiation.c b/usr.sbin/httpd/src/modules/standard/mod_negotiation.c index 1f99a7ed816..2455462fd65 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_negotiation.c +++ b/usr.sbin/httpd/src/modules/standard/mod_negotiation.c @@ -926,11 +926,7 @@ static int read_types_multi(negotiation_state *neg) request_rec *sub_req; /* Do we have a match? */ -#ifdef CASE_BLIND_FILESYSTEM - if (strncasecmp(dir_entry->d_name, filp, prefix_len)) { -#else if (strncmp(dir_entry->d_name, filp, prefix_len)) { -#endif continue; } if (dir_entry->d_name[prefix_len] != '.') { @@ -993,11 +989,7 @@ static int read_types_multi(negotiation_state *neg) saveend = *segend; *segend = '\0'; -#ifdef CASE_BLIND_FILESYSTEM - if (strcasecmp(segstart, *cur_except) == 0) { -#else if (strcmp(segstart, *cur_except) == 0) { -#endif --nexcept; ++cur_except; } diff --git a/usr.sbin/httpd/src/modules/standard/mod_rewrite.c b/usr.sbin/httpd/src/modules/standard/mod_rewrite.c index d9263109b6d..a6d90834c4b 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_rewrite.c +++ b/usr.sbin/httpd/src/modules/standard/mod_rewrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mod_rewrite.c,v 1.23 2004/12/02 19:42:48 henning Exp $ */ +/* $OpenBSD: mod_rewrite.c,v 1.24 2005/02/09 12:13:10 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -96,10 +96,8 @@ #include "http_main.h" #include "fdcache.h" -#ifndef NO_WRITEV #include <sys/types.h> #include <sys/uio.h> -#endif /* @@ -497,14 +495,9 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1, new->checkfile = a2+4; } else if (strncmp(a2, "dbm:", 4) == 0) { -#ifndef NO_DBM_REWRITEMAP new->type = MAPTYPE_DBM; new->datafile = a2+4; new->checkfile = ap_pstrcat(cmd->pool, a2+4, NDBM_FILE_SUFFIX, NULL); -#else - return ap_pstrdup(cmd->pool, "RewriteMap: cannot use NDBM mapfile, " - "because no NDBM support is compiled in"); -#endif } else if (strncmp(a2, "prg:", 4) == 0) { new->type = MAPTYPE_PRG; @@ -2907,7 +2900,6 @@ static char *lookup_map(request_rec *r, char *name, char *key) } } else if (s->type == MAPTYPE_DBM) { -#ifndef NO_DBM_REWRITEMAP if (stat(s->checkfile, &st) == -1) { ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "mod_rewrite: can't access DBM RewriteMap " @@ -2942,9 +2934,6 @@ static char *lookup_map(request_rec *r, char *name, char *key) "-> val=%s", s->name, key, value); return value[0] != '\0' ? value : NULL; } -#else - return NULL; -#endif } else if (s->type == MAPTYPE_PRG) { if ((value = @@ -3060,7 +3049,6 @@ static char *lookup_map_txtfile(request_rec *r, char *file, char *key) return value; } -#ifndef NO_DBM_REWRITEMAP static char *lookup_map_dbmfile(request_rec *r, char *file, char *key) { DBM *dbmfp = NULL; @@ -3085,16 +3073,13 @@ static char *lookup_map_dbmfile(request_rec *r, char *file, char *key) } return value; } -#endif static char *lookup_map_program(request_rec *r, int fpin, int fpout, char *key) { char buf[LONG_STRING_LEN]; char c; int i; -#ifndef NO_WRITEV struct iovec iov[2]; -#endif /* when `RewriteEngine off' was used in the per-server * context then the rewritemap-programs were not spawned. @@ -3109,16 +3094,11 @@ static char *lookup_map_program(request_rec *r, int fpin, int fpout, char *key) rewritelock_alloc(r); /* write out the request key */ -#ifdef NO_WRITEV - write(fpin, key, strlen(key)); - write(fpin, "\n", 1); -#else iov[0].iov_base = key; iov[0].iov_len = strlen(key); iov[1].iov_base = "\n"; iov[1].iov_len = 1; writev(fpin, iov, 2); -#endif /* read in the response value */ i = 0; @@ -3559,9 +3539,7 @@ static int rewritemap_program_child(void *cmd, child_info *pinfo) * Prepare for exec */ ap_cleanup_for_exec(); -#ifdef SIGHUP signal(SIGHUP, SIG_IGN); -#endif /* * Exec() the child program @@ -3817,14 +3795,12 @@ static char *lookup_variable(request_rec *r, char *var) } } -#ifdef EAPI else { ap_hook_use("ap::mod_rewrite::lookup_variable", AP_HOOK_SIG3(ptr,ptr,ptr), AP_HOOK_DECLINE(NULL), &result, r, var); } -#endif if (result == NULL) { return ap_pstrdup(r->pool, ""); @@ -4251,25 +4227,8 @@ static int prefix_stat(const char *path, ap_pool *pool) curpath += strlen(root); } else { -#if defined(HAVE_UNC_PATHS) - /* Check for UNC names. */ - if (curpath[1] == '/') { - slash = strchr(curpath + 2, '/'); - - /* XXX not sure here. Be safe for now */ - if (!slash) { - return 0; - } - root = ap_pstrndup(pool, curpath, slash - curpath + 1); - curpath += strlen(root); - } - else { -#endif /* UNC */ root = "/"; ++curpath; -#if defined(HAVE_UNC_PATHS) - } -#endif } /* let's recognize slashes only, the mod_rewrite semantics are opaque diff --git a/usr.sbin/httpd/src/modules/standard/mod_rewrite.h b/usr.sbin/httpd/src/modules/standard/mod_rewrite.h index 9dd41fa7e70..7d13aa7a2c5 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_rewrite.h +++ b/usr.sbin/httpd/src/modules/standard/mod_rewrite.h @@ -127,16 +127,14 @@ * But we have to stat the file for the mtime, * so we also need to know the file extension */ -#ifndef NO_DBM_REWRITEMAP #include <ndbm.h> #if defined(DBM_SUFFIX) #define NDBM_FILE_SUFFIX DBM_SUFFIX -#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM)) +#elif (defined(DB_LOCK) && defined(DB_SHMEM)) #define NDBM_FILE_SUFFIX ".db" #else #define NDBM_FILE_SUFFIX ".pag" #endif -#endif /* The locking support: @@ -426,9 +424,7 @@ static char *expand_tildepaths(request_rec *r, char *uri); /* rewrite map support functions */ static char *lookup_map(request_rec *r, char *name, char *key); static char *lookup_map_txtfile(request_rec *r, char *file, char *key); -#ifndef NO_DBM_REWRITEMAP static char *lookup_map_dbmfile(request_rec *r, char *file, char *key); -#endif static char *lookup_map_program(request_rec *r, int fpin, int fpout, char *key); static char *lookup_map_internal(request_rec *r, diff --git a/usr.sbin/httpd/src/modules/standard/mod_so.c b/usr.sbin/httpd/src/modules/standard/mod_so.c index 9c853b78803..e344bafca4b 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_so.c +++ b/usr.sbin/httpd/src/modules/standard/mod_so.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mod_so.c,v 1.13 2004/12/02 19:42:48 henning Exp $ */ +/* $OpenBSD: mod_so.c,v 1.14 2005/02/09 12:13:10 henning Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -158,15 +158,11 @@ static void *so_sconf_create(pool *p, server_rec *s) soc = (so_server_conf *)ap_pcalloc(p, sizeof(so_server_conf)); soc->loaded_modules = ap_make_array(p, DYNAMIC_MODULE_LIMIT, sizeof(moduleinfo)); -#ifndef NO_DLOPEN ap_os_dso_init(); -#endif return (void *)soc; } -#ifndef NO_DLOPEN - /* * This is the cleanup for a loaded shared object. It unloads the module. * This is called as a cleanup function from the core. @@ -270,24 +266,18 @@ static const char *load_module(cmd_parms *cmd, void *dummy, * Make sure the found module structure is really a module structure * */ -#ifdef EAPI if ( modp->magic != MODULE_MAGIC_COOKIE_AP13 && modp->magic != MODULE_MAGIC_COOKIE_EAPI) { -#else - if (modp->magic != MODULE_MAGIC_COOKIE) { -#endif return ap_pstrcat(cmd->pool, "API module structure `", modname, "' in file ", szModuleFile, " is garbled -" " perhaps this is not an Apache module DSO?", NULL); } -#ifdef EAPI if (modp->magic == MODULE_MAGIC_COOKIE_AP13) { ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, NULL, "Loaded DSO %s uses plain Apache 1.3 API, " "this module might crash under EAPI! " "(please recompile it with -DEAPI)", filename); } -#endif /* * Add this module to the Apache core structures @@ -343,23 +333,6 @@ static const char *load_file(cmd_parms *cmd, void *dummy, char *filename) return NULL; } -#else /* not NO_DLOPEN */ - -static const char *load_file(cmd_parms *cmd, void *dummy, char *filename) -{ - fprintf(stderr, "WARNING: LoadFile not supported on this platform\n"); - return NULL; -} - -static const char *load_module(cmd_parms *cmd, void *dummy, - char *modname, char *filename) -{ - fprintf(stderr, "WARNING: LoadModule not supported on this platform\n"); - return NULL; -} - -#endif /* NO_DLOPEN */ - static const command_rec so_cmds[] = { { "LoadModule", load_module, NULL, RSRC_CONF, TAKE2, "a module name and the name of a shared object file to load it from"}, diff --git a/usr.sbin/httpd/src/modules/standard/mod_status.c b/usr.sbin/httpd/src/modules/standard/mod_status.c index 44fc23d0246..0099117b9f4 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_status.c +++ b/usr.sbin/httpd/src/modules/standard/mod_status.c @@ -108,18 +108,6 @@ #include "scoreboard.h" #include "http_log.h" -#ifdef NEXT -#if (NX_CURRENT_COMPILER_RELEASE == 410) -#ifdef m68k -#define HZ 64 -#else -#define HZ 100 -#endif -#else -#include <machine/param.h> -#endif -#endif /* NEXT */ - #define STATUS_MAXLINE 64 #define KBYTE 1024 @@ -236,13 +224,7 @@ static int status_handler(request_rec *r) unsigned long bcount = 0; unsigned long kbcount = 0; long req_time; -#ifndef NO_TIMES -#ifdef _SC_CLK_TCK float tick = sysconf(_SC_CLK_TCK); -#else - float tick = HZ; -#endif -#endif int short_report = 0; int no_table_report = 0; short_score score_record; @@ -299,10 +281,6 @@ static int status_handler(request_rec *r) } ap_send_http_header(r); -#ifdef CHARSET_EBCDIC - /* Server-generated response, converted */ - ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1); -#endif if (r->header_only) return 0; @@ -322,12 +300,10 @@ static int status_handler(request_rec *r) lres = score_record.access_count; bytes = score_record.bytes_served; if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) { -#ifndef NO_TIMES tu += score_record.times.tms_utime; ts += score_record.times.tms_stime; tcu += score_record.times.tms_cutime; tcs += score_record.times.tms_cstime; -#endif /* NO_TIMES */ count += lres; bcount += bytes; if (bcount >= KBYTE) { @@ -368,12 +344,10 @@ static int status_handler(request_rec *r) ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n", count, kbcount); -#ifndef NO_TIMES /* Allow for OS/2 not having CPU stats */ if (ts || tu || tcu || tcs) ap_rprintf(r, "CPULoad: %g\n", (tu + ts + tcu + tcs) / tick / up_time * 100.); -#endif ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); if (up_time > 0) @@ -392,7 +366,6 @@ static int status_handler(request_rec *r) ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count); format_kbyte_out(r, kbcount); -#ifndef NO_TIMES /* Allow for OS/2 not having CPU stats */ ap_rputs("<br>\n", r); ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g", @@ -401,7 +374,6 @@ static int status_handler(request_rec *r) if (ts || tu || tcu || tcs) ap_rprintf(r, " - %.3g%% CPU load", (tu + ts + tcu + tcs) / tick / up_time * 100.); -#endif ap_rputs("<br>\n", r); @@ -491,9 +463,7 @@ static int status_handler(request_rec *r) "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>PID</b></font></td>" "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Acc</b></font></td>" "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>M</b></font></td>" -#ifndef NO_TIMES "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>CPU</b></font></td>" -#endif "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>SS</b></font></td>" "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Req</b></font></td>" "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Conn</b></font></td>" @@ -504,12 +474,7 @@ static int status_handler(request_rec *r) "<td><font face=\"Arial,Helvetica\" color=\"#ffffff\"><b>Request</b></td>" "</tr>\n", r); #else /* NO_PRETTYPRINT */ -#ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); -#else ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n", r); -#endif #endif /* NO_PRETTYPRINT */ } @@ -521,18 +486,6 @@ static int status_handler(request_rec *r) vhost = NULL; } -#if defined(NO_GETTIMEOFDAY) -#ifndef NO_TIMES - if (score_record.start_time == (clock_t) 0) -#endif /* NO_TIMES */ - req_time = 0L; -#ifndef NO_TIMES - else { - req_time = score_record.stop_time - score_record.start_time; - req_time = (req_time * 1000) / (int) tick; - } -#endif /* NO_TIMES */ -#else if (score_record.start_time.tv_sec == 0L && score_record.start_time.tv_usec == 0L) req_time = 0L; @@ -540,7 +493,6 @@ static int status_handler(request_rec *r) req_time = ((score_record.stop_time.tv_sec - score_record.start_time.tv_sec) * 1000) + ((score_record.stop_time.tv_usec - score_record.start_time.tv_usec) / 1000); -#endif if (req_time < 0L) req_time = 0L; @@ -598,22 +550,13 @@ static int status_handler(request_rec *r) ap_rputs("?STATE?", r); break; } -#ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "]\n %.0f %ld (", -#else ap_rprintf(r, "] u%g s%g cu%g cs%g\n %.0f %ld (", score_record.times.tms_utime / tick, score_record.times.tms_stime / tick, score_record.times.tms_cutime / tick, score_record.times.tms_cstime / tick, -#endif -#ifdef OPTIMIZE_TIMEOUTS difftime(nowtime, ps_record.last_rtime), -#else - difftime(nowtime, score_record.last_used), -#endif (long) req_time); format_byte_out(r, conn_bytes); ap_rputs("|", r); @@ -677,21 +620,12 @@ static int status_handler(request_rec *r) ap_rputs("<td>?", r); break; } -#ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "\n<td>%.0f<td>%ld", -#else ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld", (score_record.times.tms_utime + score_record.times.tms_stime + score_record.times.tms_cutime + score_record.times.tms_cstime) / tick, -#endif -#ifdef OPTIMIZE_TIMEOUTS difftime(nowtime, ps_record.last_rtime), -#else - difftime(nowtime, score_record.last_used), -#endif (long) req_time); ap_rprintf(r, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n", (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE, @@ -723,21 +657,6 @@ static int status_handler(request_rec *r) } /* for () */ if (!(short_report || no_table_report)) { -#ifdef NO_TIMES - ap_rputs("</table>\n \ -<hr> \ -<table>\n \ -<tr><th>Srv<td>Child Server number - generation\n \ -<tr><th>PID<td>OS process ID\n \ -<tr><th>Acc<td>Number of accesses this connection / this child / this slot\n \ -<tr><th>M<td>Mode of operation\n \ -<tr><th>SS<td>Seconds since beginning of most recent request\n \ -<tr><th>Req<td>Milliseconds required to process most recent request\n \ -<tr><th>Conn<td>Kilobytes transferred this connection\n \ -<tr><th>Child<td>Megabytes transferred this child\n \ -<tr><th>Slot<td>Total megabytes transferred this slot\n \ -</table>\n", r); -#else ap_rputs("</table>\n \ <hr> \ <table>\n \ @@ -752,14 +671,11 @@ static int status_handler(request_rec *r) <tr><th>Child<td>Megabytes transferred this child\n \ <tr><th>Slot<td>Total megabytes transferred this slot\n \ </table>\n", r); -#endif } -#ifdef EAPI ap_hook_use("ap::mod_status::display", AP_HOOK_SIG4(void,ptr,int,int), AP_HOOK_ALL, r, no_table_report, short_report); -#endif } else { diff --git a/usr.sbin/httpd/src/modules/standard/mod_unique_id.c b/usr.sbin/httpd/src/modules/standard/mod_unique_id.c index f2daa84aae7..36319a0a47a 100644 --- a/usr.sbin/httpd/src/modules/standard/mod_unique_id.c +++ b/usr.sbin/httpd/src/modules/standard/mod_unique_id.c @@ -72,9 +72,6 @@ typedef struct { unsigned int stamp; unsigned int in_addr; unsigned int pid; -#ifdef MULTITHREAD - unsigned int tid; -#endif unsigned short counter; } unique_id_rec; @@ -158,11 +155,7 @@ static unique_id_rec* get_cur_unique_id(int parent) /* * Number of elements in the structure unique_id_rec. */ -#ifdef MULTITHREAD -#define UNIQUE_ID_REC_MAX 5 -#else #define UNIQUE_ID_REC_MAX 4 -#endif static unsigned short unique_id_rec_offset[UNIQUE_ID_REC_MAX], unique_id_rec_size[UNIQUE_ID_REC_MAX], @@ -176,9 +169,7 @@ static void unique_id_global_init(server_rec *s, pool *p) #endif char str[MAXHOSTNAMELEN + 1]; struct hostent *hent; -#ifndef NO_GETTIMEOFDAY struct timeval tv; -#endif unique_id_rec *cur_unique_id = get_cur_unique_id(1); /* @@ -190,20 +181,10 @@ static void unique_id_global_init(server_rec *s, pool *p) unique_id_rec_size[1] = sizeof(cur_unique_id->in_addr); unique_id_rec_offset[2] = XtOffsetOf(unique_id_rec, pid); unique_id_rec_size[2] = sizeof(cur_unique_id->pid); -#ifdef MULTITHREAD - unique_id_rec_offset[3] = XtOffsetOf(unique_id_rec, tid); - unique_id_rec_size[3] = sizeof(cur_unique_id->tid); - unique_id_rec_offset[4] = XtOffsetOf(unique_id_rec, counter); - unique_id_rec_size[4] = sizeof(cur_unique_id->counter); - unique_id_rec_total_size = unique_id_rec_size[0] + unique_id_rec_size[1] - + unique_id_rec_size[2] + unique_id_rec_size[3] - + unique_id_rec_size[4]; -#else unique_id_rec_offset[3] = XtOffsetOf(unique_id_rec, counter); unique_id_rec_size[3] = sizeof(cur_unique_id->counter); unique_id_rec_total_size = unique_id_rec_size[0] + unique_id_rec_size[1] + unique_id_rec_size[2] + unique_id_rec_size[3]; -#endif /* * Calculate the size of the structure when encoded. @@ -248,9 +229,6 @@ static void unique_id_global_init(server_rec *s, pool *p) * But protecting against it is relatively cheap. We just sleep into the * next second. */ -#ifdef NO_GETTIMEOFDAY - sleep(1); -#else if (gettimeofday(&tv, NULL) == -1) { sleep(1); } @@ -259,15 +237,12 @@ static void unique_id_global_init(server_rec *s, pool *p) tv.tv_usec = 1000000 - tv.tv_usec; select(0, NULL, NULL, NULL, &tv); } -#endif } static void unique_id_child_init(server_rec *s, pool *p) { pid_t pid; -#ifndef NO_GETTIMEOFDAY struct timeval tv; -#endif unique_id_rec *cur_unique_id = get_cur_unique_id(1); /* @@ -297,7 +272,6 @@ static void unique_id_child_init(server_rec *s, pool *p) * against restart problems, and a little less protection against a clock * going backwards in time. */ -#ifndef NO_GETTIMEOFDAY if (gettimeofday(&tv, NULL) == -1) { cur_unique_id->counter = 0; } @@ -307,9 +281,6 @@ static void unique_id_child_init(server_rec *s, pool *p) */ cur_unique_id->counter = tv.tv_usec / 10; } -#else - cur_unique_id->counter = 0; -#endif /* * We must always use network ordering for these bytes, so that @@ -361,17 +332,6 @@ static int gen_unique_id(request_rec *r) cur_unique_id->stamp = htonl((unsigned int)r->request_time); -#ifdef MULTITHREAD - /* - * Note that we use the pid because it's possible that on the same - * physical machine there are multiple servers (i.e. using Listen). But - * it's guaranteed that none of them will share the same pid+tids between - * children. - */ - cur_unique_id->tid = gettid(); - cur_unique_id->tid = htonl(cur_unique_id->tid); -#endif - /* we'll use a temporal buffer to avoid uuencoding the possible internal * paddings of the original structure */ diff --git a/usr.sbin/httpd/src/support/ab.c b/usr.sbin/httpd/src/support/ab.c index 91de52bc578..db4c1ef1b24 100644 --- a/usr.sbin/httpd/src/support/ab.c +++ b/usr.sbin/httpd/src/support/ab.c @@ -118,9 +118,6 @@ /* -------------------------------------------------------------------- */ -/* affects include files on Solaris */ -#define BSD_COMP - /* allow compilation outside an Apache build tree */ #ifdef NO_APACHE_INCLUDES #include <sys/time.h> @@ -153,23 +150,12 @@ #endif /* NO_APACHE_INCLUDES */ #ifdef USE_SSL -#if ((!defined(RSAREF)) && (!defined(SYSSSL))) -/* Libraries on most systems.. */ #include <openssl/rsa.h> #include <openssl/crypto.h> #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/err.h> #include <openssl/ssl.h> -#else -/* Libraries for RSAref and SYSSSL */ -#include <rsa.h> -#include <crypto.h> -#include <x509.h> -#include <pem.h> -#include <err.h> -#include <ssl.h> -#endif #endif #include <math.h> @@ -1332,14 +1318,14 @@ static void test(void) static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.17 $> apache-1.3"); + printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.18 $> apache-1.3"); printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/\n"); printf("\n"); } else { printf("<p>\n"); - printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n", VERSION, "$Revision: 1.17 $"); + printf(" This is ApacheBench, Version %s <i><%s></i> apache-1.3<br>\n", VERSION, "$Revision: 1.18 $"); printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n"); printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/<br>\n"); printf("</p>\n<p>\n"); diff --git a/usr.sbin/httpd/src/support/logresolve.c b/usr.sbin/httpd/src/support/logresolve.c index aba7f602364..21950a2024e 100644 --- a/usr.sbin/httpd/src/support/logresolve.c +++ b/usr.sbin/httpd/src/support/logresolve.c @@ -80,7 +80,7 @@ struct nsrec { * statistics - obvious */ -#if !defined(h_errno) && !defined(CYGWIN) +#if !defined(h_errno) extern int h_errno; /* some machines don't have this in their headers */ #endif |