~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to include/ap_mpm.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Licensed to the Apache Software Foundation (ASF) under one or more
 
2
 * contributor license agreements.  See the NOTICE file distributed with
 
3
 * this work for additional information regarding copyright ownership.
 
4
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
5
 * (the "License"); you may not use this file except in compliance with
 
6
 * the License.  You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
/**
 
18
 * @file  ap_mmn.h
 
19
 * @brief Apache Multi-Processing Module library
 
20
 *
 
21
 * @defgroup APACHE_CORE_MPM Multi-Processing Module library
 
22
 * @ingroup  APACHE_CORE
 
23
 * @{
 
24
 */
 
25
 
 
26
#ifndef AP_MPM_H
 
27
#define AP_MPM_H
 
28
 
 
29
#include "apr_thread_proc.h"
 
30
 
 
31
/*
 
32
    The MPM, "multi-processing model" provides an abstraction of the
 
33
    interface with the OS for distributing incoming connections to
 
34
    threads/process for processing.  http_main invokes the MPM, and
 
35
    the MPM runs until a shutdown/restart has been indicated.
 
36
    The MPM calls out to the apache core via the ap_process_connection
 
37
    function when a connection arrives.
 
38
 
 
39
    The MPM may or may not be multithreaded.  In the event that it is
 
40
    multithreaded, at any instant it guarantees a 1:1 mapping of threads
 
41
    ap_process_connection invocations.  
 
42
 
 
43
    Note: In the future it will be possible for ap_process_connection
 
44
    to return to the MPM prior to finishing the entire connection; and
 
45
    the MPM will proceed with asynchronous handling for the connection;
 
46
    in the future the MPM may call ap_process_connection again -- but
 
47
    does not guarantee it will occur on the same thread as the first call.
 
48
 
 
49
    The MPM further guarantees that no asynchronous behaviour such as
 
50
    longjmps and signals will interfere with the user code that is
 
51
    invoked through ap_process_connection.  The MPM may reserve some
 
52
    signals for its use (i.e. SIGUSR1), but guarantees that these signals
 
53
    are ignored when executing outside the MPM code itself.  (This
 
54
    allows broken user code that does not handle EINTR to function
 
55
    properly.)
 
56
 
 
57
    The suggested server restart and stop behaviour will be "graceful".
 
58
    However the MPM may choose to terminate processes when the user
 
59
    requests a non-graceful restart/stop.  When this occurs, the MPM kills
 
60
    all threads with extreme prejudice, and destroys the pchild pool.
 
61
    User cleanups registered in the pchild apr_pool_t will be invoked at
 
62
    this point.  (This can pose some complications, the user cleanups
 
63
    are asynchronous behaviour not unlike longjmp/signal... but if the
 
64
    admin is asking for a non-graceful shutdown, how much effort should
 
65
    we put into doing it in a nice way?)
 
66
 
 
67
    unix/posix notes:
 
68
    - The MPM does not set a SIGALRM handler, user code may use SIGALRM.
 
69
        But the preferred method of handling timeouts is to use the
 
70
        timeouts provided by the BUFF abstraction.
 
71
    - The proper setting for SIGPIPE is SIG_IGN, if user code changes it
 
72
        for any of their own processing, it must be restored to SIG_IGN
 
73
        prior to executing or returning to any apache code.
 
74
    TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN
 
75
*/
 
76
 
 
77
/**
 
78
 * This is the function that MPMs must create.  This function is responsible
 
79
 * for controlling the parent and child processes.  It will run until a 
 
80
 * restart/shutdown is indicated.
 
81
 * @param pconf the configuration pool, reset before the config file is read
 
82
 * @param plog the log pool, reset after the config file is read
 
83
 * @param server_conf the global server config.
 
84
 * @return 1 for shutdown 0 otherwise.
 
85
 * @deffunc int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)
 
86
 */
 
87
AP_DECLARE(int) ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf);
 
88
 
 
89
/**
 
90
 * predicate indicating if a graceful stop has been requested ...
 
91
 * used by the connection loop 
 
92
 * @return 1 if a graceful stop has been requested, 0 otherwise
 
93
 * @deffunc int ap_graceful_stop_signalled(*void)
 
94
 */
 
95
AP_DECLARE(int) ap_graceful_stop_signalled(void);
 
96
 
 
97
/**
 
98
 * Spawn a process with privileges that another module has requested
 
99
 * @param r The request_rec of the current request
 
100
 * @param newproc The resulting process handle.
 
101
 * @param progname The program to run 
 
102
 * @param const_args the arguments to pass to the new program.  The first 
 
103
 *                   one should be the program name.
 
104
 * @param env The new environment apr_table_t for the new process.  This 
 
105
 *            should be a list of NULL-terminated strings.
 
106
 * @param attr the procattr we should use to determine how to create the new
 
107
 *         process
 
108
 * @param p The pool to use. 
 
109
 */
 
110
AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
 
111
    const request_rec *r,
 
112
    apr_proc_t *newproc, 
 
113
    const char *progname,
 
114
    const char * const *args, 
 
115
    const char * const *env,
 
116
    apr_procattr_t *attr, 
 
117
    apr_pool_t *p);
 
118
 
 
119
/* Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED        */
 
120
#define AP_MPMQ_NOT_SUPPORTED      0  /* This value specifies whether */
 
121
                                      /* an MPM is capable of         */
 
122
                                      /* threading or forking.        */
 
123
#define AP_MPMQ_STATIC             1  /* This value specifies whether */
 
124
                                      /* an MPM is using a static #   */
 
125
                                      /* threads or daemons.          */
 
126
#define AP_MPMQ_DYNAMIC            2  /* This value specifies whether */
 
127
                                      /* an MPM is using a dynamic #  */
 
128
                                      /* threads or daemons.          */
 
129
 
 
130
/* Values returned for AP_MPMQ_MPM_STATE */
 
131
#define AP_MPMQ_STARTING              0
 
132
#define AP_MPMQ_RUNNING               1
 
133
#define AP_MPMQ_STOPPING              2
 
134
 
 
135
#define AP_MPMQ_MAX_DAEMON_USED       1  /* Max # of daemons used so far */
 
136
#define AP_MPMQ_IS_THREADED           2  /* MPM can do threading         */
 
137
#define AP_MPMQ_IS_FORKED             3  /* MPM can do forking           */
 
138
#define AP_MPMQ_HARD_LIMIT_DAEMONS    4  /* The compiled max # daemons   */
 
139
#define AP_MPMQ_HARD_LIMIT_THREADS    5  /* The compiled max # threads   */
 
140
#define AP_MPMQ_MAX_THREADS           6  /* # of threads/child by config */
 
141
#define AP_MPMQ_MIN_SPARE_DAEMONS     7  /* Min # of spare daemons       */
 
142
#define AP_MPMQ_MIN_SPARE_THREADS     8  /* Min # of spare threads       */
 
143
#define AP_MPMQ_MAX_SPARE_DAEMONS     9  /* Max # of spare daemons       */
 
144
#define AP_MPMQ_MAX_SPARE_THREADS    10  /* Max # of spare threads       */
 
145
#define AP_MPMQ_MAX_REQUESTS_DAEMON  11  /* Max # of requests per daemon */
 
146
#define AP_MPMQ_MAX_DAEMONS          12  /* Max # of daemons by config   */
 
147
#define AP_MPMQ_MPM_STATE            13  /* starting, running, stopping  */
 
148
#define AP_MPMQ_IS_ASYNC             14  /* MPM can process async connections  */
 
149
 
 
150
/**
 
151
 * Query a property of the current MPM.  
 
152
 * @param query_code One of APM_MPMQ_*
 
153
 * @param result A location to place the result of the query
 
154
 * @return APR_SUCCESS or APR_ENOTIMPL
 
155
 * @deffunc int ap_mpm_query(int query_code, int *result)
 
156
 */
 
157
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result);
 
158
 
 
159
/* Defining GPROF when compiling uses the moncontrol() function to
 
160
 * disable gprof profiling in the parent, and enable it only for
 
161
 * request processing in children (or in one_process mode).  It's
 
162
 * absolutely required to get useful gprof results under linux
 
163
 * because the profile itimers and such are disabled across a
 
164
 * fork().  It's probably useful elsewhere as well.
 
165
 */
 
166
#ifdef GPROF
 
167
extern void moncontrol(int);
 
168
#define AP_MONCONTROL(x) moncontrol(x)
 
169
#else
 
170
#define AP_MONCONTROL(x)
 
171
#endif
 
172
 
 
173
#if AP_ENABLE_EXCEPTION_HOOK
 
174
typedef struct ap_exception_info_t {
 
175
    int sig;
 
176
    pid_t pid;
 
177
} ap_exception_info_t;
 
178
 
 
179
AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei))
 
180
#endif /*AP_ENABLE_EXCEPTION_HOOK*/
 
181
 
 
182
#endif
 
183
/** @} */