Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

beos.c File Reference

#include <kernel/OS.h>
#include <unistd.h>
#include <sys/socket.h>
#include <signal.h>
#include "apr_strings.h"
#include "apr_portable.h"
#include "httpd.h"
#include "http_main.h"
#include "http_log.h"
#include "http_config.h"
#include "http_core.h"
#include "http_connection.h"
#include "ap_mpm.h"
#include "beosd.h"
#include "ap_listen.h"
#include "scoreboard.h"
#include "mpm_common.h"
#include "mpm.h"
#include "mpm_default.h"
#include "apr_thread_mutex.h"
#include "apr_poll.h"

Include dependency graph for beos.c:

Go to the source code of this file.

Defines

#define CORE_PRIVATE
#define HARD_SERVER_LIMIT   1
#define HARD_THREAD_LIMIT   50
#define MAX_SPAWN_RATE   (32)

Functions

int _kset_fd_limit_ (int num)
static void check_restart (void *data)
static void clean_child_exit (int code)
static void sig_coredump (int sig)
static void ap_start_shutdown (void)
static void ap_start_restart (int graceful)
static void sig_term (int sig)
static void restart (int sig)
static void tell_workers_to_exit (void)
static void set_signals (void)
int ap_graceful_stop_signalled (void)
static void process_socket (apr_pool_t *p, apr_socket_t *sock, int my_child_num, apr_bucket_alloc_t *bucket_alloc)
static int32 worker_thread (void *dummy)
static int make_worker (int slot)
static void startup_threads (int number_to_start)
static void perform_idle_server_maintenance (void)
static void server_main_loop (int remaining_threads_to_start)
 AP_DECLARE (apr_status_t)
int ap_mpm_run (apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
static int beos_pre_config (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
static void beos_hooks (apr_pool_t *p)
static const char * set_threads_to_start (cmd_parms *cmd, void *dummy, const char *arg)
static const char * set_min_spare_threads (cmd_parms *cmd, void *dummy, const char *arg)
static const char * set_max_spare_threads (cmd_parms *cmd, void *dummy, const char *arg)
static const char * set_threads_limit (cmd_parms *cmd, void *dummy, const char *arg)
static const char * set_max_requests_per_thread (cmd_parms *cmd, void *dummy, const char *arg)

Variables

static int ap_threads_to_start = 0
static int ap_max_requests_per_thread = 0
static int min_spare_threads = 0
static int max_spare_threads = 0
static int ap_thread_limit = 0
static int num_listening_sockets = 0
static apr_socket_t ** listening_sockets
apr_thread_mutex_taccept_mutex = NULL
static apr_pool_tpconf
static apr_pool_tpchild
static int server_pid
static int mpm_state = AP_MPMQ_STARTING
static int worker_thread_count
apr_thread_mutex_tworker_thread_count_mutex
int ap_max_child_assigned = -1
int ap_max_threads_limit = -1
static apr_socket_tudp_sock
static apr_sockaddr_tudp_sa
server_recap_server_conf
static int one_process = 0
static int volatile shutdown_pending
static int volatile restart_pending
static int volatile is_graceful
static int volatile child_fatal
ap_generation_t volatile ap_my_generation = 0
static int spawn_rate = 1
static int hold_off_on_exponential_spawning
static const command_rec beos_cmds []
module AP_MODULE_DECLARE_DATA mpm_beos_module


Define Documentation

#define CORE_PRIVATE
 

Definition at line 25 of file beos.c.

#define HARD_SERVER_LIMIT   1
 

Definition at line 66 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_child_main(), ap_mpm_run(), and master_main().

#define HARD_THREAD_LIMIT   50
 

Definition at line 79 of file beos.c.

Referenced by add_worker(), AP_DECLARE(), ap_mpm_child_main(), ap_mpm_run(), beos_pre_config(), mpmt_os2_pre_config(), netware_pre_config(), server_maintenance(), set_thread_limit(), set_threads_limit(), and thread_exception_handler().

#define MAX_SPAWN_RATE   (32)
 

Definition at line 569 of file beos.c.

Referenced by perform_child_maintenance(), and perform_idle_server_maintenance().


Function Documentation

int _kset_fd_limit_ int  num  ) 
 

Referenced by ap_mpm_run().

AP_DECLARE apr_status_t   ) 
 

convert a recent time to its human readable components in local timezone

Parameters:
tm the exploded time
t the time to explode: MUST be within the last AP_TIME_RECENT_THRESHOLD seconds
Note:
This is a faster alternative to apr_explode_localtime that uses a cache of pre-exploded time structures. It is useful for things that need to explode the current time multiple times per second, like loggers.
Returns:
APR_SUCCESS iff successful

Definition at line 696 of file beos.c.

References AP_DECLARE, ap_max_child_assigned, ap_max_requests_per_thread, AP_MPMQ_DYNAMIC, AP_MPMQ_HARD_LIMIT_DAEMONS, AP_MPMQ_HARD_LIMIT_THREADS, AP_MPMQ_IS_FORKED, AP_MPMQ_IS_THREADED, AP_MPMQ_MAX_DAEMON_USED, AP_MPMQ_MAX_DAEMONS, AP_MPMQ_MAX_REQUESTS_DAEMON, AP_MPMQ_MAX_SPARE_DAEMONS, AP_MPMQ_MAX_SPARE_THREADS, AP_MPMQ_MAX_THREADS, AP_MPMQ_MIN_SPARE_DAEMONS, AP_MPMQ_MIN_SPARE_THREADS, AP_MPMQ_MPM_STATE, AP_MPMQ_NOT_SUPPORTED, APR_ENOTIMPL, APR_SUCCESS, HARD_SERVER_LIMIT, HARD_THREAD_LIMIT, max_spare_threads, min_spare_threads, and mpm_state.

int ap_graceful_stop_signalled void   ) 
 

Definition at line 285 of file beos.c.

References is_graceful.

Referenced by ap_process_http_connection().

int ap_mpm_run apr_pool_t _pconf,
apr_pool_t plog,
server_rec s
 

Definition at line 742 of file beos.c.

References _kset_fd_limit_(), ap_listeners, ap_pid_fname, ap_scoreboard_image, ap_setup_listeners(), ap_thread_limit, ap_threads_to_start, APLOG_ALERT, APLOG_EMERG, APLOG_ERR, APLOG_INFO, APLOG_MARK, APLOG_NOTICE, APLOG_WARNING, apr_bind(), apr_pool_create, apr_socket_close(), apr_socket_create(), APR_SUCCESS, APR_UNSPEC, beosd_killpg, child_fatal, apr_sockaddr_t::family, FD_SETSIZE, getpid, HARD_SERVER_LIMIT, HARD_THREAD_LIMIT, hold_off_on_exponential_spawning, is_graceful, lr, max_spare_threads, min_spare_threads, NULL, num_listening_sockets, OK, one_process, scoreboard::parent, process_score::pid, process_rec::pool, server_rec::process, restart_pending, SB_SHARED, ap_listen_rec::sd, server_main_loop(), scoreboard::servers, set_signals(), shutdown_pending, proc_info::slot, startup_threads(), tell_workers_to_exit(), proc_info::tpool, and worker_thread().

Referenced by main().

Here is the call graph for this function:

static void ap_start_restart int  graceful  )  [static]
 

Definition at line 204 of file beos.c.

References AP_MPMQ_STOPPING, is_graceful, mpm_state, and restart_pending.

Referenced by restart().

static void ap_start_shutdown void   )  [static]
 

Definition at line 189 of file beos.c.

References AP_MPMQ_STOPPING, mpm_state, and shutdown_pending.

Referenced by sig_term().

static void beos_hooks apr_pool_t p  )  [static]
 

Definition at line 1033 of file beos.c.

References APR_HOOK_REALLY_FIRST, beos_pre_config(), NULL, and one_process.

Here is the call graph for this function:

static int beos_pre_config apr_pool_t pconf,
apr_pool_t plog,
apr_pool_t ptemp
[static]
 

Definition at line 978 of file beos.c.

References ap_coredump_dir, ap_listen_pre_config(), ap_max_requests_per_thread, AP_MPMQ_STARTING, ap_pid_fname, ap_server_root, ap_thread_limit, ap_threads_to_start, APLOG_CRIT, APLOG_MARK, APR_ALLOCATOR_MAX_FREE_UNLIMITED, apr_proc_detach(), APR_PROC_DETACH_DAEMONIZE, APR_PROC_DETACH_FOREGROUND, APR_SUCCESS, beosd_pre_config(), debug, DEFAULT_MAX_FREE_THREADS, DEFAULT_MAX_REQUESTS_PER_THREAD, DEFAULT_MIN_FREE_THREADS, DEFAULT_PIDLOG, DEFAULT_START_THREADS, getpid, HARD_THREAD_LIMIT, HTTP_INTERNAL_SERVER_ERROR, is_graceful, max_spare_threads, min_spare_threads, mpm_state, NULL, OK, one_process, and server_pid.

Referenced by beos_hooks().

Here is the call graph for this function:

static void check_restart void *  data  )  [static]
 

Definition at line 534 of file beos.c.

References APLOG_INFO, APLOG_MARK, int, make_worker(), NULL, restart_pending, and shutdown_pending.

Referenced by worker_thread().

Here is the call graph for this function:

static void clean_child_exit int  code  )  [static]
 

Definition at line 137 of file beos.c.

References exit.

Referenced by accept_mutex_on(), ap_mpm_child_main(), child_main(), create_listener_thread(), just_die(), make_child(), make_worker(), start_threads(), and worker_main().

static int make_worker int  slot  )  [static]
 

Definition at line 487 of file beos.c.

References ap_max_child_assigned, ap_scoreboard_image, APEXIT_CHILDFATAL, APLOG_ALERT, APLOG_ERR, APLOG_MARK, apr_pool_create, clean_child_exit(), getpid, NULL, one_process, scoreboard::parent, process_score::pid, SERVER_DEAD, SERVER_STARTING, scoreboard::servers, set_signals(), proc_info::slot, proc_info::tpool, void(), and worker_thread().

Referenced by check_restart(), perform_idle_server_maintenance(), server_main_loop(), and startup_threads().

Here is the call graph for this function:

static void perform_idle_server_maintenance void   )  [static]
 

Definition at line 573 of file beos.c.

References ap_max_child_assigned, ap_scoreboard_image, ap_thread_limit, hold_off_on_exponential_spawning, make_worker(), MAX_SPAWN_RATE, scoreboard::servers, and spawn_rate.

Referenced by ap_mpm_run(), and server_main_loop().

Here is the call graph for this function:

static void process_socket apr_pool_t p,
apr_socket_t sock,
int  my_child_num,
apr_bucket_alloc_t bucket_alloc
[static]
 

Definition at line 295 of file beos.c.

References APLOG_MARK, APLOG_WARNING, apr_os_sock_get(), apr_socket_close(), FD_SETSIZE, NULL, and void().

Referenced by worker_thread().

Here is the call graph for this function:

static void restart int  sig  )  [static]
 

Definition at line 221 of file beos.c.

References ap_start_restart().

Referenced by ap_mpm_run(), CommandLineInterpreter(), and set_signals().

Here is the call graph for this function:

static void server_main_loop int  remaining_threads_to_start  )  [static]
 

Definition at line 617 of file beos.c.

References ap_max_child_assigned, ap_scoreboard_image, ap_thread_limit, APEXIT_CHILDFATAL, APLOG_MARK, APLOG_WARNING, child_fatal, child_slot, exitwhy, is_graceful, make_worker(), NULL, perform_idle_server_maintenance(), apr_proc_t::pid, restart_pending, SERVER_DEAD, scoreboard::servers, shutdown_pending, startup_threads(), status, and void().

Referenced by ap_mpm_run().

Here is the call graph for this function:

static const char* set_max_requests_per_thread cmd_parms cmd,
void *  dummy,
const char *  arg
[static]
 

Definition at line 1115 of file beos.c.

References ap_max_requests_per_thread, APLOG_MARK, APLOG_STARTUP, err, GLOBAL_ONLY, and NULL.

static const char* set_max_spare_threads cmd_parms cmd,
void *  dummy,
const char *  arg
[static]
 

Definition at line 1077 of file beos.c.

References err, GLOBAL_ONLY, max_spare_threads, and NULL.

static const char* set_min_spare_threads cmd_parms cmd,
void *  dummy,
const char *  arg
[static]
 

Definition at line 1056 of file beos.c.

References APLOG_MARK, APLOG_STARTUP, err, GLOBAL_ONLY, min_spare_threads, and NULL.

static void set_signals void   )  [static]
 

Definition at line 240 of file beos.c.

References APLOG_MARK, APLOG_WARNING, NULL, one_process, restart(), sig_coredump(), and sig_term().

Referenced by ap_mpm_child_main(), ap_mpm_run(), make_child(), make_worker(), and master_main().

Here is the call graph for this function:

static const char* set_threads_limit cmd_parms cmd,
void *  dummy,
const char *  arg
[static]
 

Definition at line 1088 of file beos.c.

References ap_thread_limit, APLOG_MARK, APLOG_STARTUP, err, GLOBAL_ONLY, HARD_THREAD_LIMIT, and NULL.

static const char* set_threads_to_start cmd_parms cmd,
void *  dummy,
const char *  arg
[static]
 

Definition at line 1040 of file beos.c.

References ap_threads_to_start, APLOG_MARK, APLOG_STARTUP, err, GLOBAL_ONLY, and NULL.

static void sig_coredump int  sig  )  [static]
 

Definition at line 145 of file beos.c.

References ap_coredump_dir, and server_pid.

Referenced by set_signals().

static void sig_term int  sig  )  [static]
 

Definition at line 216 of file beos.c.

References ap_start_shutdown().

Referenced by set_signals().

Here is the call graph for this function:

static void startup_threads int  number_to_start  )  [static]
 

Definition at line 545 of file beos.c.

References ap_scoreboard_image, ap_thread_limit, make_worker(), and scoreboard::servers.

Referenced by ap_mpm_run(), and server_main_loop().

Here is the call graph for this function:

static void tell_workers_to_exit void   )  [static]
 

Definition at line 226 of file beos.c.

References ap_max_child_assigned, AP_MPMQ_STOPPING, apr_sendto(), APR_SUCCESS, len, and mpm_state.

Referenced by ap_mpm_run().

Here is the call graph for this function:

static int32 worker_thread void *  dummy  )  [static]
 

Definition at line 325 of file beos.c.

References allocator, ap_listeners, ap_max_requests_per_thread, AP_MPMQ_RUNNING, AP_MPMQ_STARTING, APLOG_ERR, APLOG_MARK, APLOG_NOTICE, apr_accept(), APR_EINIT, APR_POLLIN, apr_recvfrom(), APR_STATUS_IS_EINTR, APR_SUCCESS, APR_UNSPEC, check_restart(), child_slot, event, len, mpm_state, n, NULL, num_listening_sockets, pollset, process_socket(), ptrans, requests_this_child, ap_listen_rec::sd, SERVER_DEAD, SERVER_READY, SERVER_STARTING, proc_info::slot, proc_info::tpool, void(), and worker_thread_count.

Referenced by ap_mpm_run(), make_worker(), start_thread(), and start_threads().

Here is the call graph for this function:


Variable Documentation

apr_thread_mutex_t* accept_mutex = NULL
 

Definition at line 93 of file beos.c.

Referenced by ap_mpm_run(), and master_main().

int ap_max_child_assigned = -1
 

Definition at line 118 of file beos.c.

Referenced by AP_DECLARE(), make_worker(), perform_idle_server_maintenance(), server_main_loop(), and tell_workers_to_exit().

int ap_max_requests_per_thread = 0 [static]
 

Definition at line 87 of file beos.c.

Referenced by AP_DECLARE(), beos_pre_config(), set_max_requests_per_thread(), and worker_thread().

int ap_max_threads_limit = -1
 

Definition at line 119 of file beos.c.

ap_generation_t volatile ap_my_generation = 0
 

Definition at line 168 of file beos.c.

server_rec* ap_server_conf
 

Definition at line 126 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_child_main(), pod_signal_internal(), server_maintenance(), set_signals(), thread_exception_handler(), and worker_main().

int ap_thread_limit = 0 [static]
 

Definition at line 90 of file beos.c.

Referenced by ap_mpm_run(), beos_pre_config(), mpmt_os2_pre_config(), perform_idle_server_maintenance(), server_main_loop(), set_threads_limit(), and startup_threads().

int ap_threads_to_start = 0 [static]
 

Definition at line 86 of file beos.c.

Referenced by ap_mpm_run(), beos_pre_config(), netware_pre_config(), and set_threads_to_start().

const command_rec beos_cmds[] [static]
 

Initial value:

 {
BEOS_DAEMON_COMMANDS,
LISTEN_COMMANDS,
AP_INIT_TAKE1( "StartThreads", set_threads_to_start, NULL, RSRC_CONF,
  "Number of threads to launch at server startup"),
AP_INIT_TAKE1( "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF,
  "Minimum number of idle children, to handle request spikes"),
AP_INIT_TAKE1( "MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF,
  "Maximum number of idle children" ),
AP_INIT_TAKE1( "MaxClients", set_threads_limit, NULL, RSRC_CONF, 
  "Maximum number of children alive at the same time (max threads)" ),
AP_INIT_TAKE1( "MaxRequestsPerThread", set_max_requests_per_thread, NULL, RSRC_CONF,
  "Maximum number of requests served by a thread" ),
{ NULL }
}

Definition at line 1133 of file beos.c.

int volatile child_fatal [static]
 

Definition at line 167 of file beos.c.

Referenced by ap_mpm_run(), and server_main_loop().

int hold_off_on_exponential_spawning [static]
 

Definition at line 571 of file beos.c.

Referenced by ap_mpm_run(), perform_child_maintenance(), and perform_idle_server_maintenance().

int volatile is_graceful [static]
 

Definition at line 166 of file beos.c.

Referenced by ap_graceful_stop_signalled(), ap_mpm_child_main(), ap_mpm_run(), ap_start_restart(), beos_pre_config(), master_main(), mpmt_os2_pre_config(), netware_pre_config(), perchild_pre_config(), restart(), server_main_loop(), sig_hup(), sig_restart(), and sig_term().

apr_socket_t** listening_sockets [static]
 

Definition at line 92 of file beos.c.

int max_spare_threads = 0 [static]
 

Definition at line 89 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_run(), beos_pre_config(), leader_pre_config(), perchild_pre_config(), perform_idle_server_maintenance(), set_max_spare_threads(), worker_pre_config(), and worker_thread().

int min_spare_threads = 0 [static]
 

Definition at line 88 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_run(), beos_pre_config(), leader_pre_config(), perchild_pre_config(), perform_idle_server_maintenance(), set_min_spare_threads(), worker_pre_config(), and worker_thread().

module AP_MODULE_DECLARE_DATA mpm_beos_module
 

Initial value:

 {
    MPM20_MODULE_STUFF,
    NULL,                       
    NULL,                       
    NULL,                       
    NULL,                       
    NULL,                       
    beos_cmds,          
    beos_hooks          
}

Definition at line 1149 of file beos.c.

int mpm_state = AP_MPMQ_STARTING [static]
 

Definition at line 99 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_run(), ap_start_restart(), ap_start_shutdown(), beos_pre_config(), child_main(), clean_child_exit(), leader_pre_config(), netware_pre_config(), prefork_pre_config(), signal_threads(), tell_workers_to_exit(), worker_pre_config(), and worker_thread().

int num_listening_sockets = 0 [static]
 

Definition at line 91 of file beos.c.

Referenced by ap_mpm_run(), and worker_thread().

int one_process = 0 [static]
 

Definition at line 129 of file beos.c.

Referenced by AP_DECLARE(), ap_mpm_run(), beos_hooks(), beos_pre_config(), child_main(), leader_hooks(), leader_open_logs(), leader_pre_config(), make_child(), make_worker(), master_main(), mpmt_os2_pre_config(), perchild_hooks(), perchild_pre_config(), perchild_setup_child(), set_signals(), threadpool_hooks(), worker_hooks(), worker_open_logs(), and worker_pre_config().

apr_pool_t* pchild [static]
 

Definition at line 96 of file beos.c.

apr_pool_t* pconf [static]
 

Definition at line 95 of file beos.c.

int volatile restart_pending [static]
 

Definition at line 165 of file beos.c.

Referenced by ap_mpm_run(), ap_start_restart(), check_restart(), master_main(), restart(), server_main_loop(), sig_restart(), and worker_main().

int server_pid [static]
 

Definition at line 98 of file beos.c.

Referenced by beos_pre_config(), and sig_coredump().

int volatile shutdown_pending [static]
 

Definition at line 164 of file beos.c.

Referenced by ap_mpm_child_main(), ap_mpm_run(), ap_start_shutdown(), check_restart(), clean_child_exit(), CommandLineInterpreter(), master_main(), nlmUnloadSignaled(), server_main_loop(), sig_hup(), sig_term(), thread_exception_handler(), and worker_main().

int spawn_rate = 1 [static]
 

Definition at line 567 of file beos.c.

Referenced by perform_child_maintenance(), and perform_idle_server_maintenance().

apr_sockaddr_t* udp_sa [static]
 

Definition at line 122 of file beos.c.

apr_socket_t* udp_sock [static]
 

Definition at line 121 of file beos.c.

int worker_thread_count [static]
 

Definition at line 102 of file beos.c.

Referenced by ap_mpm_run(), child_main(), clean_child_exit(), start_thread(), worker_main(), and worker_thread().

apr_thread_mutex_t* worker_thread_count_mutex
 

Definition at line 103 of file beos.c.