The following patch adds a new include, ap_os.h that has defines for some of the functions that are currently found in the unixd.h type headers. It moves these to ap_os and tries to provide no-op functions for them as appropriate.
This patch enables the worker mpm to build on beos and should lead to having a single MPM that can at least be built and run on all platforms. Tested OK on FreeBSD, Solaris (Aaron) and BeOS. Aaron gives it +1 Thougts? david Index: server/listen.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/listen.c,v retrieving revision 1.66 diff -u -r1.66 listen.c --- server/listen.c 8 Dec 2001 01:38:05 -0000 1.66 +++ server/listen.c 29 Dec 2001 00:23:25 -0000 @@ -71,6 +71,7 @@ #include "http_log.h" #include "mpm.h" #include "mpm_common.h" +#include "ap_os.h" ap_listen_rec *ap_listeners; #if APR_HAVE_IPV6 Index: server/mpm_common.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v retrieving revision 1.76 diff -u -r1.76 mpm_common.c --- server/mpm_common.c 18 Dec 2001 13:48:52 -0000 1.76 +++ server/mpm_common.c 29 Dec 2001 00:23:27 -0000 @@ -84,6 +84,7 @@ #include "ap_mpm.h" #include "ap_listen.h" #include "mpm_default.h" +#include "ap_os.h" #ifdef AP_MPM_WANT_SET_SCOREBOARD #include "scoreboard.h" @@ -94,6 +95,27 @@ #endif #ifdef HAVE_GRP_H #include <grp.h> +#endif + +#ifdef AP_OS_SETUP_CHILD_IS_NOOP +AP_DECLARE(int) ap_os_setup_child(void) +{ + return 0; +} +#endif + +#ifdef AP_OS_USER_GROUP_ARE_NOOP +AP_DECLARE(const char *) ap_os_set_user (cmd_parms *cmd, void *dummy, + const char *arg) +{ + return NULL; +} + +AP_DECLARE(const char *) ap_os_set_group(cmd_parms *cmd, void *dummy, + const char *arg) +{ + return NULL; +} #endif #ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES Index: server/mpm/beos/beos.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v retrieving revision 1.74 diff -u -r1.74 beos.c --- server/mpm/beos/beos.c 18 Dec 2001 13:48:53 -0000 1.74 +++ server/mpm/beos/beos.c 29 Dec 2001 00:23:38 -0000 @@ -75,7 +75,7 @@ #include "http_core.h" /* for get_remote_host */ #include "http_connection.h" #include "ap_mpm.h" -#include "beosd.h" +#include "ap_os.h" #include "ap_listen.h" #include "scoreboard.h" #include <kernel/OS.h> @@ -948,7 +948,7 @@ /* Time to gracefully shut down: * Kill child processes, tell them to call child_exit, etc... */ - if (beosd_killpg(getpgrp(), SIGTERM) < 0) + if (ap_os_killpg(getpgrp(), SIGTERM) < 0) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM"); @@ -1015,7 +1015,7 @@ server_pid = getpid(); } - beosd_pre_config(); + ap_os_pre_config(ptemp); ap_listen_pre_config(); ap_threads_to_start = DEFAULT_START_THREADS; min_spare_threads = DEFAULT_MIN_FREE_THREADS; @@ -1129,7 +1129,7 @@ } static const command_rec beos_cmds[] = { -BEOS_DAEMON_COMMANDS, +AP_OS_DAEMON_COMMANDS, LISTEN_COMMANDS, AP_INIT_TAKE1( "StartThreads", set_threads_to_start, NULL, RSRC_CONF, "Number of threads to launch at server startup"), Index: server/mpm/prefork/mpm.h =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/mpm.h,v retrieving revision 1.17 diff -u -r1.17 mpm.h --- server/mpm/prefork/mpm.h 13 Nov 2001 22:42:38 -0000 1.17 +++ server/mpm/prefork/mpm.h 29 Dec 2001 00:23:38 -0000 @@ -59,7 +59,7 @@ #include "httpd.h" #include "mpm_default.h" #include "scoreboard.h" -#include "unixd.h" +#include "ap_os.h" #ifndef APACHE_MPM_PREFORK_H #define APACHE_MPM_PREFORK_H @@ -83,7 +83,7 @@ #define MPM_SYNC_CHILD_TABLE() (ap_sync_scoreboard_image()) #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) #define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) -#define MPM_ACCEPT_FUNC unixd_accept +#define MPM_ACCEPT_FUNC ap_os_accept extern int ap_threads_per_child; extern int ap_max_daemons_limit; Index: server/mpm/prefork/prefork.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v retrieving revision 1.226 diff -u -r1.226 prefork.c --- server/mpm/prefork/prefork.c 19 Dec 2001 14:49:22 -0000 1.226 +++ server/mpm/prefork/prefork.c 29 Dec 2001 00:23:39 -0000 @@ -596,7 +596,7 @@ reopen_scoreboard(pchild); SAFE_ACCEPT(accept_mutex_child_init(pchild)); - if (unixd_setup_child()) { + if (ap_os_setup_child()) { clean_child_exit(APEXIT_CHILDFATAL); } @@ -1127,7 +1127,7 @@ /* Time to gracefully shut down: * Kill child processes, tell them to call child_exit, etc... */ - if (unixd_killpg(getpgrp(), SIGTERM) < 0) { + if (ap_os_killpg(getpgrp(), SIGTERM) < 0) { ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGTERM"); } ap_reclaim_child_processes(1); /* Start with SIGTERM */ @@ -1186,7 +1186,7 @@ } else { /* Kill 'em off */ - if (unixd_killpg(getpgrp(), SIGHUP) < 0) { + if (ap_os_killpg(getpgrp(), SIGHUP) < 0) { ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "killpg SIGHUP"); } ap_reclaim_child_processes(0); /* Not when just starting up */ @@ -1223,7 +1223,7 @@ parent_pid = ap_my_pid = getpid(); } - unixd_pre_config(ptemp); + ap_os_pre_config(ptemp); ap_listen_pre_config(); ap_daemons_to_start = DEFAULT_START_DAEMON; ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON; @@ -1358,7 +1358,7 @@ } static const command_rec prefork_cmds[] = { -UNIX_DAEMON_COMMANDS, +AP_OS_DAEMON_COMMANDS, LISTEN_COMMANDS, AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF, "Number of child processes launched at server startup"), Index: server/mpm/worker/mpm.h =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/worker/mpm.h,v retrieving revision 1.7 diff -u -r1.7 mpm.h --- server/mpm/worker/mpm.h 25 Dec 2001 02:30:53 -0000 1.7 +++ server/mpm/worker/mpm.h 29 Dec 2001 00:23:40 -0000 @@ -56,7 +56,6 @@ * University of Illinois, Urbana-Champaign. */ #include "scoreboard.h" -#include "unixd.h" #ifndef APACHE_MPM_WORKER_H #define APACHE_MPM_WORKER_H @@ -81,7 +80,7 @@ #define MPM_SYNC_CHILD_TABLE() (ap_sync_scoreboard_image()) #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) #define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) -#define MPM_ACCEPT_FUNC unixd_accept +#define MPM_ACCEPT_FUNC ap_os_accept extern int ap_threads_per_child; extern int ap_max_daemons_limit; Index: server/mpm/worker/worker.c =================================================================== RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v retrieving revision 1.56 diff -u -r1.56 worker.c --- server/mpm/worker/worker.c 27 Dec 2001 23:40:55 -0000 1.56 +++ server/mpm/worker/worker.c 29 Dec 2001 00:23:42 -0000 @@ -106,6 +106,7 @@ #include "scoreboard.h" #include "fdqueue.h" #include "mpm_default.h" +#include "ap_os.h" #include <signal.h> #include <limits.h> /* for INT_MAX */ @@ -915,7 +916,7 @@ clean_child_exit(APEXIT_CHILDFATAL); } - if (unixd_setup_child()) { + if (ap_os_setup_child()) { clean_child_exit(APEXIT_CHILDFATAL); } @@ -1611,7 +1612,7 @@ parent_pid = ap_my_pid = getpid(); } - unixd_pre_config(ptemp); + ap_os_pre_config(ptemp); ap_listen_pre_config(); ap_daemons_to_start = DEFAULT_START_DAEMON; min_spare_threads = DEFAULT_MIN_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD; @@ -1850,7 +1851,7 @@ } static const command_rec worker_cmds[] = { -UNIX_DAEMON_COMMANDS, +AP_OS_DAEMON_COMMANDS, LISTEN_COMMANDS, AP_INIT_TAKE1("StartServers", set_daemons_to_start, NULL, RSRC_CONF, "Number of child processes launched at server startup"), Index: os/beos/beosd.c =================================================================== RCS file: /home/cvs/httpd-2.0/os/beos/beosd.c,v retrieving revision 1.18 diff -u -r1.18 beosd.c --- os/beos/beosd.c 23 Dec 2001 14:13:07 -0000 1.18 +++ os/beos/beosd.c 29 Dec 2001 00:23:42 -0000 @@ -61,59 +61,11 @@ #include "http_config.h" #include "http_main.h" #include "http_log.h" -#include "beosd.h" +#include "ap_os.h" #include "apr_lock.h" #include "mpm_common.h" -beosd_config_rec beosd_config; - -/* Set group privileges. - * - * Note that until we get the multi-user situation sorted on beos, - * this is just a no-op to allow common configuration files! - */ - -#if B_BEOS_VERSION < 0x0460 -static int set_group_privs(void) -{ - /* no-op */ - return 0; -} -#endif - - -int beosd_setup_child(void) -{ - /* TODO: revisit the whole issue of users/groups for BeOS as - * R5 and below doesn't really have much concept of them. - */ - - return 0; -} - - -AP_DECLARE(const char *) beosd_set_user(cmd_parms *cmd, - void *dummy, const char *arg) -{ - /* no-op */ - return NULL; -} - -AP_DECLARE(const char *) beosd_set_group(cmd_parms *cmd, - void *dummy, const char *arg) -{ - /* no-op */ - return NULL; -} - -void beosd_pre_config(void) -{ - /* Until the multi-user situation on BeOS is fixed, - simply have a no-op here to allow for common conf files - */ -} - -AP_DECLARE(apr_status_t) beosd_accept(void **accepted, ap_listen_rec *lr, +AP_DECLARE(apr_status_t) ap_os_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans) { apr_socket_t *csd; @@ -121,6 +73,7 @@ int sockdes; status = apr_accept(&csd, lr->sd, ptrans); + if (status == APR_SUCCESS) { *accepted = csd; apr_os_sock_get(&sockdes, csd); Index: os/beos/os.c =================================================================== RCS file: /home/cvs/httpd-2.0/os/beos/os.c,v retrieving revision 1.12 diff -u -r1.12 os.c --- os/beos/os.c 23 Aug 2001 19:08:20 -0000 1.12 +++ os/beos/os.c 29 Dec 2001 00:23:42 -0000 @@ -62,7 +62,6 @@ */ #include "ap_config.h" -#include "os.h" #include "httpd.h" #include "apr_thread_proc.h" #include "ap_mpm.h" /* needed for definition of Index: os/beos/os.h =================================================================== RCS file: /home/cvs/httpd-2.0/os/beos/os.h,v retrieving revision 1.13 diff -u -r1.13 os.h --- os/beos/os.h 23 Aug 2001 19:08:20 -0000 1.13 +++ os/beos/os.h 29 Dec 2001 00:23:42 -0000 @@ -69,4 +69,10 @@ #endif #endif +#define AP_OS_USER_GROUP_ARE_NOOP +#define AP_OS_SETUP_CHILD_IS_NOOP +#define AP_OS_PRE_CONFIG_IS_NOOP + +static const char *fname; + #endif /* !APACHE_OS_H */ Index: os/netware/os.h =================================================================== RCS file: /home/cvs/httpd-2.0/os/netware/os.h,v retrieving revision 1.2 diff -u -r1.2 os.h --- os/netware/os.h 29 Oct 2001 22:55:13 -0000 1.2 +++ os/netware/os.h 29 Dec 2001 00:23:42 -0000 @@ -73,4 +73,8 @@ #define getpid NXThreadGetId #define exit(s) if(s){pressanykey();apr_terminate();}exit(s); +#define AP_OS_USER_GROUP_ARE_NOOP +#define AP_OS_PRE_CONFIG_IS_NOOP +#define AP_OS_SETUP_CHILD_IS_NOOP + #endif /* ! APACHE_OS_H */ Index: os/os2/os.h =================================================================== RCS file: /home/cvs/httpd-2.0/os/os2/os.h,v retrieving revision 1.18 diff -u -r1.18 os.h --- os/os2/os.h 24 Aug 2001 03:02:57 -0000 1.18 +++ os/os2/os.h 29 Dec 2001 00:23:42 -0000 @@ -72,4 +72,8 @@ * and prototypes of OS specific functions defined in os.c or os-inline.c */ +#define AP_OS_USER_GROUP_ARE_NOOP +#define AP_OS_PRE_CONFIG_IS_NOOP +#define AP_OS_SETUP_CHILD_IS_NOOP + #endif /* ! APACHE_OS_H */ Index: os/unix/unixd.c =================================================================== RCS file: /home/cvs/httpd-2.0/os/unix/unixd.c,v retrieving revision 1.43 diff -u -r1.43 unixd.c --- os/unix/unixd.c 27 Dec 2001 19:53:37 -0000 1.43 +++ os/unix/unixd.c 29 Dec 2001 00:23:43 -0000 @@ -65,7 +65,7 @@ #include "unixd.h" #include "apr_lock.h" #include "mpm_common.h" -#include "os.h" +#include "ap_os.h" #include "ap_mpm.h" #include "apr_thread_proc.h" #include "apr_strings.h" @@ -152,7 +152,7 @@ } -AP_DECLARE(int) unixd_setup_child(void) +AP_DECLARE(int) ap_os_setup_child(void) { if (set_group_privs()) { return -1; @@ -187,7 +187,7 @@ } -AP_DECLARE(const char *) unixd_set_user(cmd_parms *cmd, void *dummy, +AP_DECLARE(const char *) ap_os_set_user(cmd_parms *cmd, void *dummy, const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -214,7 +214,7 @@ return NULL; } -AP_DECLARE(const char *) unixd_set_group(cmd_parms *cmd, void *dummy, +AP_DECLARE(const char *) ap_os_set_group(cmd_parms *cmd, void *dummy, const char *arg) { const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -227,7 +227,7 @@ return NULL; } -AP_DECLARE(void) unixd_pre_config(apr_pool_t *ptemp) +AP_DECLARE(void) ap_os_pre_config(apr_pool_t *ptemp) { apr_finfo_t wrapper; @@ -442,7 +442,7 @@ return APR_SUCCESS; } -AP_DECLARE(apr_status_t) unixd_accept(void **accepted, ap_listen_rec *lr, +AP_DECLARE(apr_status_t) ap_os_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans) { apr_socket_t *csd; Index: os/unix/unixd.h =================================================================== RCS file: /home/cvs/httpd-2.0/os/unix/unixd.h,v retrieving revision 1.32 diff -u -r1.32 unixd.h --- os/unix/unixd.h 25 Dec 2001 12:24:14 -0000 1.32 +++ os/unix/unixd.h 29 Dec 2001 00:23:43 -0000 @@ -109,32 +109,24 @@ } unixd_config_rec; AP_DECLARE_DATA extern unixd_config_rec unixd_config; -AP_DECLARE(int) unixd_setup_child(void); -AP_DECLARE(void) unixd_pre_config(apr_pool_t *ptemp); -AP_DECLARE(const char *) unixd_set_user(cmd_parms *cmd, void *dummy, - const char *arg); -AP_DECLARE(const char *) unixd_set_group(cmd_parms *cmd, void *dummy, - const char *arg); #if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) AP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char *arg, const char * arg2, int type); #endif + AP_DECLARE(apr_status_t) unixd_set_lock_perms(apr_lock_t *lock); AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex); -AP_DECLARE(apr_status_t) unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans); + #ifdef HAVE_KILLPG -#define unixd_killpg(x, y) (killpg ((x), (y))) -#define ap_os_killpg(x, y) (killpg ((x), (y))) +#define unixd_killpg(x, y) (killpg ((x), (y))) +#ifdef ap_os_killpg + #undef ap_os_killpg + #define ap_os_killpg(x, y) (killpg ((x), (y))) +#endif #else /* HAVE_KILLPG */ -#define unixd_killpg(x, y) (kill (-(x), (y))) -#define ap_os_killpg(x, y) (kill (-(x), (y))) +#define unixd_killpg(x, y) (kill (-(x), (y))) #endif /* HAVE_KILLPG */ -#define UNIX_DAEMON_COMMANDS \ -AP_INIT_TAKE1("User", unixd_set_user, NULL, RSRC_CONF, \ - "Effective user id for this server"), \ -AP_INIT_TAKE1("Group", unixd_set_group, NULL, RSRC_CONF, \ - "Effective group id for this server") #endif Index: os/win32/os.h =================================================================== RCS file: /home/cvs/httpd-2.0/os/win32/os.h,v retrieving revision 1.49 diff -u -r1.49 os.h --- os/win32/os.h 24 Aug 2001 03:02:57 -0000 1.49 +++ os/win32/os.h 29 Dec 2001 00:23:44 -0000 @@ -87,4 +87,8 @@ #include <stddef.h> +#define AP_OS_USER_GROUP_ARE_NOOP +#define AP_OS_PRE_CONFIG_IS_NOOP +#define AP_OS_SETUP_CHILD_IS_NOOP + #endif /* ! APACHE_OS_H */ /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. */ #ifndef AP_OS_H #define AP_OS_H #include "ap_config.h" #include "ap_listen.h" #include "os.h" AP_DECLARE(int) ap_os_setup_child(void); #ifndef AP_OS_PRE_CONFIG_IS_NOOP AP_DECLARE(void) ap_os_pre_config(apr_pool_t *p); #else #define ap_os_pre_config(p) #endif /* These are the standard things an MPM should recognise, * but if they aren't implemented they should simply return NULL */ AP_DECLARE(const char *) ap_os_set_user (cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE(const char *) ap_os_set_group(cmd_parms *cmd, void *dummy, const char *arg); /* Used by the workerMPM at present... */ AP_DECLARE(apr_status_t) ap_os_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans); /* These can be overridden by a platform if required. */ #ifndef AP_OS_DAEMON_COMMANDS #define AP_OS_DAEMON_COMMANDS \ AP_INIT_TAKE1("User", ap_os_set_user, NULL, RSRC_CONF, \ "Effective user id for this server"), \ AP_INIT_TAKE1("Group", ap_os_set_group, NULL, RSRC_CONF, \ "Effective group id for this server") #endif #ifndef ap_os_killpg #define ap_os_killpg(x, y) kill(-(x), (y)) #endif #endif